---@diagnostic disable: trailing-space
local extension = Package:new("moepack_heart")
extension.extensionName = "moepack"

Fk:loadTranslationTable{
  ["moepack_heart"] = "萌包-心动",
}

local U = require "packages/utility/utility"
local MoeFunc = require "packages/moepack/moepack_function"

local moe__junsheng = General(extension, "moe__junsheng", "moe", 4, 4, General.Female)

local emo__junce = fk.CreateViewAsSkill{
  name = "emo__junce",
  pattern = "fire_attack,iron_chain,collateral,nullification",
  anim_type = "control",
  interaction = function(self)
    local mark = Self:getTableMark("emo__junce-turn")
    local names = {}
    for _, name in ipairs(self.pattern:split(",")) do
      local card = Fk:cloneCard(name)
      if not table.contains(mark ,name) and ((Fk.currentResponsePattern == nil and Self:canUse(card)) or
        (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(card))) then
        table.insertIfNeed(names, name)
      end
    end
    if #names == 0 then return end
    return UI.ComboBox {choices = names}
  end,
  card_num = 1,
  card_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  view_as = function(self, cards)
    if not self.interaction.data or #cards ~= 1 then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcard(cards[1])
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local mark = player:getTableMark("emo__junce-turn")
    table.insert(mark, use.card.name)
    room:setPlayerMark(player, "emo__junce-turn", mark)
  end,
  enabled_at_play = function(self, player)
    local mark = player:getTableMark("emo__junce-turn")
    return #mark < 4
  end,
  enabled_at_response = function(self, player)
    local mark = player:getTableMark("emo__junce-turn")
    return not table.contains(mark, "nullification")
  end,
}
moe__junsheng:addSkill(emo__junce)

local emo__junshi = fk.CreateTriggerSkill{
  name = "emo__junshi",
  anim_type = "control",
  events = {fk.TargetSpecified , fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if not (target == player and player:hasSkill(self) and data.card.type == Card.TypeTrick) then return false end
    local id
    if event == fk.TargetSpecified then
      id = data.to
    else
      if data.responseToEvent and data.responseToEvent.from then
        id = data.responseToEvent.from
      end
    end
    if id and id ~= player.id and not player.room:getPlayerById(id):isKongcheng() then
      self.cost_data = id
      return true
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    return room:askForSkillInvoke(player, self.name, nil, "#emo__junshi-invoke:"..self.cost_data)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    if to:isKongcheng() then return end
    local card = room:askForCard(to, 1, 1, false, self.name, false, ".", "#emo__junshi-recast")
    room:recastCard(card, to, self.name)
    local id = card[1]
    if Fk:getCardById(id).type == Card.TypeBasic and room:getCardArea(id) == Card.DiscardPile and not player.dead then
      room:obtainCard(player, id, true, fk.ReasonPrey)
    end
  end,
}

moe__junsheng:addSkill(emo__junshi)

Fk:loadTranslationTable{
  ["moe__junsheng"] = "军神",

  ["emo__junce"] = "军策",
  [":emo__junce"] = "每回合每牌名限一次，你可以将一张牌当【火攻】/【铁锁连环】/【借刀杀人】/【无懈可击】使用。",

  ["emo__junshi"] = "军势",
  [":emo__junshi"] = "每当你使用锦囊牌指定其他角色为目标或响应其他角色后，你可以令其重铸一张手牌，若重铸了基本牌你获得之。",
  ["#emo__junshi-invoke"] = "军势：你可以令 %src 重铸一张手牌，若重铸了基本牌，你获得之",
  ["#emo__junshi-recast"] = "军势：请重铸一张手牌",
}

local moe__chiling = General(extension, "moe__chiling", "moe", 3, 3, General.Female)

local emo__youling = fk.CreateTriggerSkill{
  name = "emo__youling",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished, fk.TurnEnd, fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if event == fk.AfterCardsMove then
      if player:hasSkill(self) then
        for _, move in ipairs(data) do
          if move.extra_data and move.extra_data.emo__youling then
            return true
          end
        end
      end
    elseif event == fk.TurnEnd then
      return target == player and player:hasSkill(self)
    else
      return target == player and player:hasSkill(self) and player.phase ~= Player.NotActive
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.CardUseFinished then
      room:addPlayerMark(player, "emo__youling_maxcards-turn")
      room:broadcastProperty(player, "MaxCards")
    elseif event == fk.TurnEnd then
      local cards = {}
      local n = 5
      for _, id in ipairs(player:getCardIds("h")) do
        local card = Fk:getCardById(id)
        if card:getMark("@@emo__youling-inhand") > 0 then
          n = n - 1
        else
          table.insert(cards, card)
        end
      end
      if n > 0 and #cards > 0 then
        for _, c in ipairs(table.random(cards, n)) do
          room:setCardMark(c, "@@emo__youling-inhand", 1)
        end
      end
    else
      -- 别给move的data加上extra_data
      local n = 0
      for _, move in ipairs(data) do
        if move.extra_data and move.extra_data.emo__youling then
          n = n + move.extra_data.emo__youling
        end
      end
      player:drawCards(n, self.name)
    end
  end,

  refresh_events = {fk.BeforeCardsMove},
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(self) then
      for _, move in ipairs(data) do
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand and Fk:getCardById(info.cardId):getMark("@@emo__youling-inhand") > 0 then
              return true
            end
          end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      local n = 0
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand and Fk:getCardById(info.cardId):getMark("@@emo__youling-inhand") > 0 then
            n = n + 1
          end
        end
      end
      if n > 0 then
        move.extra_data = move.extra_data or {}
        move.extra_data.emo__youling = n
      end
    end
  end,
}
local emo__youling_maxcards = fk.CreateMaxCardsSkill{
  name = "#emo__youling_maxcards",
  correct_func = function(self, player)
    return player:getMark("emo__youling_maxcards-turn")
  end,
}
emo__youling:addRelatedSkill(emo__youling_maxcards)

moe__chiling:addSkill(emo__youling)

local emo__duxi = fk.CreateTriggerSkill{
  name = "emo__duxi",
  anim_type = "defensive",
  events = {fk.TargetSpecified },
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.to == player.id and player.shield < 5
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeShield(player, 1)
  end,
}
moe__chiling:addSkill(emo__duxi)

Fk:loadTranslationTable{
  ["moe__chiling"] = "赤零",

  ["emo__youling"] = "优伶",
  [":emo__youling"] = "锁定技，每当你于回合内使用牌后，本回合手牌上限+1。回合结束时，标记所有手牌为“伶”（“伶”至多有五张），当你失去“伶”时摸一张牌。",
  ["@@emo__youling-inhand"] = "伶",

  ["emo__duxi"] = "独戏",
  [":emo__duxi"] = "锁定技，你使用牌指定自己为目标后，你获得一点护甲。",
}

local moe__xunyicao = General(extension, "moe__xunyicao", "moe", 4, 4, General.Female)

local emo__wuzhuang = fk.CreateTriggerSkill{
  name = "emo__wuzhuang",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and not table.contains(player.sealedSlots, Player.WeaponSlot)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if table.find(target:getEquipments(Card.SubtypeWeapon), function(cid) return Fk:getCardById(cid).name == "assault_rifle" end) then
      room:addPlayerMark(player, "@ARbullet")
      player:drawCards(1, self.name)
    else
      local cardId = MoeFunc.getDerivedCard(room, "assault_rifle")
      if cardId and room:getCardArea(cardId) ~= Card.PlayerSpecial then
        room:moveCardIntoEquip(player, cardId, self.name, true, player)
      end
    end
  end,
}
moe__xunyicao:addSkill(emo__wuzhuang)

local emo__jundao = fk.CreateTriggerSkill{
  name = "emo__jundao",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and player.phase == Player.Finish then
      local n = 0
      player.room.logic:getActualDamageEvents(1, function(e)
        if e.data[1].from == player then
          n = n + e.data[1].damage
        end
        if n > 1 then return true end
      end) 
      return n > 1
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local choices = {"draw2"}
    if player.shield < 5 then 
      table.insert(choices, "gainShield")
      if player:getMark("@ARbullet") >= 2 then
        table.insert(choices, "emo__jundao_beishui")
      end
    end
    table.insert(choices, "cancel")
    local choice = room:askForChoice(player, choices, self.name)
    if choice ~= "cancel" then
      self.cost_data = choice
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = self.cost_data
    if choice == "emo__jundao_beishui" then
      room:removePlayerMark(player, "@ARbullet", 2)
    end
    if choice == "draw2" or choice == "emo__jundao_beishui" then
      player:drawCards(2, self.name)
    end
    if choice == "gainShield" or choice == "emo__jundao_beishui" then
      room:changeShield(player, 1)
    end
  end,
}
moe__xunyicao:addSkill(emo__jundao)

Fk:loadTranslationTable{
  ["moe__xunyicao"] = "薰衣草",

  ["emo__wuzhuang"] = "武装",
  [":emo__wuzhuang"] = "锁定技，回合开始时，将【突击步枪】置入装备区，若已装备【突击步枪】，你摸一张牌并获得1枚“子弹”。",

  ["emo__jundao"] = "军刀",
  [":emo__jundao"] = "结束阶段，若本回合你造成至少2点伤害，你可以选一项：1.摸两张牌；2.获得1点护甲。背水：消耗2枚“子弹”。",
  ["gainShield"] = "获得护甲",
  ["emo__jundao_beishui"] = "背水：消耗4枚子弹",
}

local moe__shala = General(extension, "moe__shala", "moe", 4, 4, General.Female)

local emo__huiwu = fk.CreateTriggerSkill{
  name = "emo__huiwu",
  anim_type = "control",
  events = {fk.TargetConfirmed },
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and data.card.trueName == "slash" and data.from ~= player.id then
      local from = player.room:getPlayerById(data.from)
      return not from.dead and player:canUseTo(Fk:cloneCard("attract_lightning"), from)
    end
    
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__huiwu-invoke:"..data.from)
  end,
  on_use = function(self, event, target, player, data)
    player.room:useVirtualCard("attract_lightning", nil, player, player.room:getPlayerById(data.from), self.name)
  end,
}

moe__shala:addSkill(emo__huiwu)

local emo__xuanji = fk.CreateViewAsSkill{
  name = "emo__xuanji",
  anim_type = "control",
  pattern = "nullification",
  prompt = function ()
    return "#emo__xuanji-prompt:::"..(4 - Self:getMark("emo__xuanji-round"))
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    local card = Fk:cloneCard("nullification")
    card.skillName = self.name
    return card
  end,
  before_use = function (self, player, use)
    local room = player.room
    local cards = room:getNCards(4 - player:getMark("emo__xuanji-round"))
    local trick = table.filter(cards, function(id) return Fk:getCardById(id).type == Card.TypeTrick end)
    local chosen, _ = U.askforChooseCardsAndChoice(player, trick, {"OK"}, self.name, "#emo__xuanji-card", {"Cancel"}, 1, 1, cards)
    if #chosen == 0 then
      room:addPlayerMark(player, "emo__xuanji-round")
      return self.name
    else
      use.card:addSubcard(chosen[1])
      use.disresponsiveList = table.map(room.alive_players, Util.IdMapper)
    end
  end,
  enabled_at_response = function(self, player)
    return player:getMark("emo__xuanji-round") < 4
  end,
}
moe__shala:addSkill(emo__xuanji)


Fk:loadTranslationTable{
  ["moe__shala"] = "沙拉",

  ["emo__huiwu"] = "会悟",
  [":emo__huiwu"] = "每当你成为其他角色使用【杀】的目标后，你可以视为对其使用一张【引雷】。",
  ["#emo__huiwu-invoke"] = "会悟:你可以视为对 %src 使用一张【引雷】",

  ["emo__xuanji"] = "玄机",
  [":emo__xuanji"] = "当你需要使用【无懈可击】时，你可以观看牌堆顶四张牌，然后可以将其中一张锦囊牌当不可被响应的【无懈可击】使用，若你没有选择牌，本轮以此法观看的牌数-1。",
  ["#emo__xuanji-card"] = "玄机：选择一张锦囊牌当【无懈可击】使用",
  ["#emo__xuanji-prompt"] = "玄机：可以观看牌堆顶 %arg 张牌，将其中一张锦囊牌当【无懈可击】使用",
}

local moe__nuoer = General(extension, "moe__nuoer", "moe", 4, 4, General.Female)

local emo__zaohuo = fk.CreateActiveSkill{
  name = "emo__zaohuo",
  anim_type = "offensive",
  prompt = "#emo__zaohuo-prompt",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  min_target_num = 1,
  max_target_num = 2,
  target_filter = function(self, to_select, selected)
    return Self:canUseTo(Fk:cloneCard("fire_attack"), Fk:currentRoom():getPlayerById(to_select)) and #selected < 2
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:useVirtualCard("fire_attack", nil, player, table.map(effect.tos, Util.Id2PlayerMapper), self.name, true)
  end,
}

local emo__zaohuo_trigger = fk.CreateTriggerSkill{
  name = "#emo__zaohuo_trigger",
  anim_type = "offensive",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.name == "fire_attack" and data.damageDealt
    and table.find(player.room.alive_players, function (p) return data.damageDealt[p.id] end)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p) return data.damageDealt[p.id] end)
    for _, p in ipairs(targets) do
      if not p.dead then
        room:doIndicate(player.id, {p.id})
        p:drawCards(1, "emo__zaohuo")
        room:delay(200)
      end
    end
    local card = Fk:cloneCard("fire_attack")
    card.skillName = "emo__zaohuo"
    targets = table.filter(targets, function (p) return player:canUseTo(card, p) end)
    if #targets == 0 or player.dead then return end
    room:useCard({
      from = player.id,
      tos = table.map(targets, function(p) return {p.id} end),
      card = card,
      additionalDamage = (data.additionalDamage or 0) + 1,
      extraUse = true,
    })
  end,
}
emo__zaohuo:addRelatedSkill(emo__zaohuo_trigger)

moe__nuoer:addSkill(emo__zaohuo)

local emo__yibi = fk.CreateTriggerSkill{
  name = "emo__yibi",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.phase == Player.Start and target:isWounded()
    and (player:distanceTo(target) == 1 or target == player)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__yibi-invoke:"..target.id) 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(target, "emo__yibi-turn", 1)
    local x = target.maxHp - target:getHandcardNum() 
    if x > 0 then
      target:drawCards(x, self.name)
    end
  end,
}
local emo__yibi_maxcards = fk.CreateMaxCardsSkill{
  name = "#emo__yibi_maxcards",
  fixed_func = function(self, player)
    if player:getMark("emo__yibi-turn") > 0 then
      return player.maxHp
    end
  end
}
emo__yibi:addRelatedSkill(emo__yibi_maxcards)
moe__nuoer:addSkill(emo__yibi)

Fk:loadTranslationTable{
  ["moe__nuoer"] = "诺尔",

  ["emo__zaohuo"] = "造火",
  [":emo__zaohuo"] = "①出牌阶段限一次，你可以视为对至多两名角色使用一张【火攻】。②你使用【火攻】结算后，你令所有受到此牌伤害的角色摸一张牌，然后视为对这些角色使用一张伤害基数+1的【火攻】。",
  ["#emo__zaohuo_trigger"] = "造火",
  ["#emo__zaohuo-prompt"] = "造火：视为对至多两名角色使用【火攻】",

  ["emo__yibi"] = "翼蔽",
  [":emo__yibi"] = "你距离1以内的角色准备阶段开始时，若其已受伤，你可令将手牌摸至体力上限，且其本回合手牌上限等于体力上限。",
  ["#emo__yibi-invoke"] = "翼蔽：你可令 %src 将手牌摸至体力上限，且其本回合手牌上限等于体力上限",
}

local moe__heimei = General(extension, "moe__heimei", "moe", 4, 4, General.Female)

local emo__qianmian = fk.CreateTriggerSkill{
  name = "emo__qianmian",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.GameStart, fk.Damaged, fk.CardUseFinished, fk.CardRespondFinished},
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(self) then
      if event == fk.GameStart then
        return true
      elseif target == player and player:getMark("@emo__qianmian") ~= 0 then
        if event == fk.Damaged then
          return player:hasSkill(player:getMark("@emo__qianmian"), true)
        else
          return table.contains(data.card.skillNames, player:getMark("@emo__qianmian"))
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skills = room:getTag("emo__qianmian_skills")
    if skills == nil then
      skills = {}
      local QianmianBanList = {
        "liangyuan" , "zhangdeng" , "danying", "fengying" , "lingyin" , "emo__cangyun", "zhenyi", "jibing", "fuping",
        "ty__fanghun", "fanghun", "os__fanghun",
      }
      local acceptableEvents = {fk.CardUsing, fk.CardUseFinished, fk.TargetSpecified, fk.TargetSpecifying, fk.AfterCardTargetDeclared}
      -- 排除一些主技能实际上是触发技的转化技能，例如双雄
      local triggerCheck = function (skill)
        return not table.find(skill.related_skills, function(s)
          return s:isInstanceOf(TriggerSkill) and s.events 
          and table.find(s.events, function(e) return not table.contains(acceptableEvents, e) end)
        end)
      end
      for _, name in ipairs(room.general_pile) do
        local general = Fk.generals[name]
        for _, skill in ipairs(general.skills) do
          if skill:isInstanceOf(ViewAsSkill) and not table.contains(QianmianBanList, skill.name) and triggerCheck(skill) then
            if not (skill.lordSkill or skill.switchSkillName or skill.frequency > 3) then
              table.insertIfNeed(skills, skill.name)
            end
          end
        end
      end
      room:setTag("emo__qianmian_skills", skills)
    end
    skills = table.filter(skills, function(s)
      local skill = Fk.skills[s]
      return not player:hasSkill(skill, true) 
      and (#skill.attachedKingdom == 0 or table.contains(skill.attachedKingdom, player.kingdom))
    end)
    if event == fk.GameStart then
      if #skills == 0 then return end
      local skill = room:askForChoice(player, table.random(skills, 3), self.name, "#emo__qianmian-skill", true)
      room:setPlayerMark(player, "@emo__qianmian", skill)
      room:handleAddLoseSkills(player, skill)
    else
      local mark = player:getMark("@emo__qianmian")
      player:drawCards(1, self.name)
      if #skills == 0 then return end
      local skill = table.random(skills)
      room:setPlayerMark(player, "@emo__qianmian", skill)
      room:handleAddLoseSkills(player, "-"..mark.."|"..skill)
    end
  end,

  on_lose = function (self, player, is_death)
    local mark = player:getMark("@emo__qianmian")
    if mark == 0 then return end
    local room = player.room
    room:setPlayerMark(player, "@emo__qianmian", 0)
    room:handleAddLoseSkills(player, "-"..mark, nil)
  end,
}
moe__heimei:addSkill(emo__qianmian)

Fk:loadTranslationTable{
  ["moe__heimei"] = "黑梅",
  ["#moe__heimei"] = "千思万面",

  ["emo__qianmian"] = "千面",
  [":emo__qianmian"] = "锁定技，游戏开始时，你获得一个转化技。每当你以此法使用或打出牌后，或你受到伤害后，你摸一张牌并随机更换为新的转化技。",
  ["#emo__qianmian-skill"] = "千面：请选择一个技能获得！",
  ["@emo__qianmian"] = "千面",
}

local moe__haila = General(extension, "moe__haila", "moe", 4, 4, General.Female)

local emo__jipao = fk.CreateTriggerSkill{
  name = "emo__jipao",
  anim_type = "drawcard",
  events = {fk.DrawNCards},
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.n = data.n + 2
    room:addPlayerMark(player, "emo__jipao-turn")
    room:broadcastProperty(player, "MaxCards")
  end,
}

local emo__jipao_maxcards = fk.CreateMaxCardsSkill{
  name = "#emo__jipao_maxcards",
  fixed_func = function(self, player)
    if player:hasSkill(self) and player:getMark("emo__jipao-turn") > 0 then
      return 2
    end
  end
}

emo__jipao:addRelatedSkill(emo__jipao_maxcards)

moe__haila:addSkill(emo__jipao)

local emo__xiongmo = fk.CreateTriggerSkill{
  name = "emo__xiongmo",
  anim_type = "offensive",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.damage
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
    "#emo__xiongmo-choose:::"..data.damage.damage, self.name, true)
    if #tos > 0 then
      self.cost_data = {tos = tos}
      return true
    end
  end,  
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    room:damage { from = player, to = to, damage = data.damage.damage, skillName = self.name }
    player:throwAllCards("h")
  end,
}
moe__haila:addSkill(emo__xiongmo)


Fk:loadTranslationTable{
  ["moe__haila"] = "海拉",
  
  ["emo__jipao"] = "疾跑",
  [":emo__jipao"] = "摸牌阶段，你可以额外摸两张牌，若如此做，本回合你手牌上限为2。",
  
  ["emo__xiongmo"] = "凶末",
  [":emo__xiongmo"] = "每当你因受到伤害而进入濒死时，你可以对一名其他角色造成X点伤害（X为你受到的伤害值），然后你弃置所有手牌。",
  ["#emo__xiongmo-choose"] = "凶末：你可以对一名其他角色造成%arg点伤害，然后弃置所有手牌",
}

local moe__chuying = General(extension, "moe__chuying", "moe", 4, 4, General.Female)

local emo__xiehu = fk.CreateActiveSkill{
  name = "emo__xiehu",
  anim_type = "support",
  prompt = function (self)
    return self.interaction.data or ""
  end,
  can_use = function(self, player)
    return table.find({"basic", "trick", "equip"}, function (ch)
      return player:getMark("emo__xiehu_"..ch.."-phase") == 0
    end)
  end,
  interaction = function(self)
    local all_choices = {"emo__xiehu_basic", "emo__xiehu_trick", "emo__xiehu_equip"}
    local choices = {}
    if Self:getMark("emo__xiehu_basic-phase") == 0 then
      table.insert(choices, "emo__xiehu_basic")
    end
    if Self:getMark("emo__xiehu_trick-phase") == 0 and #Self:getAvailableEquipSlots() > 0 then
      table.insert(choices, "emo__xiehu_trick")
    end
    if Self:getMark("emo__xiehu_equip-phase") == 0 and not Self:isKongcheng() then
      table.insert(choices, "emo__xiehu_equip")
    end
    if #choices > 0 then
      return UI.ComboBox { choices = choices, all_choices = all_choices }
    end
  end,
  min_card_num = 0,
  card_filter = function(self, to_select, selected)
    return self.interaction.data == "emo__xiehu_equip" and #selected == 0 and table.contains(Self.player_cards[Player.Hand], to_select) 
  end,
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards)
    return self.interaction.data ~= "emo__xiehu_equip" or #selected_cards == 1
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local choice = self.interaction.data
    room:setPlayerMark(player, choice.."-phase", 1)
    local cardType = choice:sub(-5, -1)
    if cardType == "basic" then
      room:loseHp(player, 1, self.name)
    elseif cardType == "trick" then
      local slot = room:askForChoice(player, player:getAvailableEquipSlots(), self.name)
      room:abortPlayerArea(player, slot)
    else
      room:moveCards{
        from = player.id,
        ids = effect.cards,
        toArea = Card.DrawPile,
        moveReason = fk.ReasonPut,
        drawPilePosition = -1,
      }
    end
    local to = room:getPlayerById(effect.tos[1])
    if to.dead then return end
    local ids = room:getCardsFromPileByRule(".|.|.|.|.|"..cardType, to == player and 1 or 2, "allPiles")
    if #ids > 0 then
      room:moveCardTo(ids, Player.Hand, to, fk.ReasonJustMove, self.name, nil, false, player.id)
    end
  end,
}
moe__chuying:addSkill(emo__xiehu)

local emo__zhenchi = fk.CreateTriggerSkill{
  name = "emo__zhenchi",
  events = {fk.AskForCardUse},
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      (data.cardName == "jink" or (data.pattern and Exppattern:Parse(data.pattern):matchExp("jink|.|.|none")))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(1, "bottom")
    room:moveCards({
      ids = cards,
      toArea = Card.Processing,
      moveReason = fk.ReasonPut,
      skillName = self.name,
      proposer = player.id,
    })
    local card = Fk:getCardById(cards[1])
    if card.name == "jink" and not player:prohibitUse(card) then
      data.result = {
        from = player.id,
        card = card,
      }
      if data.eventData then
        data.result.toCard = data.eventData.toCard
        data.result.responseToEvent = data.eventData.responseToEvent
      end
      return true
    elseif card.trueName == "slash" and not player:prohibitUse(card) and data.eventData and data.eventData.from then
      local to = room:getPlayerById(data.eventData.from)
      if to and not to.dead and not player:isProhibited(to, card) then
        room:useCard{from = player.id, tos = {{to.id}}, card = card, extraUse = true}
      end
    end
    if room:getCardArea(cards[1]) == Card.Processing then
      room:moveCards({
        ids = cards,
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonPutIntoDiscardPile,
      })
    end
  end
}
moe__chuying:addSkill(emo__zhenchi)


Fk:loadTranslationTable{
  ["moe__chuying"] = "雏鹰",
  
  ["emo__xiehu"] = "携护",
  [":emo__xiehu"] = "出牌阶段各限一次，你可以失去1点体力/废除1个装备栏/将1张手牌置于牌堆底，令一名角色获得1张基本牌/锦囊牌/装备牌，若其不为你，其额外获得1张。",
  ["emo__xiehu_basic"] = "失去1点体力令一名角色获得基本牌",
  ["emo__xiehu_trick"] = "废除1个装备栏令一名角色获得锦囊牌",
  ["emo__xiehu_equip"] = "将1张手牌置于牌堆底令令一名角色获得装备牌",

  ["emo__zhenchi"] = "振翅",
  [":emo__zhenchi"] = "当你需要使用【闪】时，你可以亮出牌堆底牌，若为【闪】你使用之，若为【杀】你对需要响应牌的使用者使用之，否则此牌置入弃牌堆。",
}

local moe__mofei = General(extension, "moe__mofei", "moe", 4, 4, General.Female)

-- 只要出牌阶段主动发动、且自己参与的拼点
local lunshi_skills = {
  "tianyi", "quhu",
  "js__luxun","shidu","qyt__jueji","ty__fenglue","kannan","gushe","ty_ex__xianzhen","ty_ex__qiaoshui","mobile__yizheng",
  "yangjie", "mini_delu","changshi__yaozhuo","dahe","ty__songshu","kuangzhan","kannan","os__qinghan","ty__fenyue",
  "yangming", "qiantun",
  "sxfy__wuyou","os__xuechang", "feixiong",
  "emo__yinglue",
  "sw_kaipai","sw_tazhan",
  "zx_heg__yichi",
}

local emo__lunshi = fk.CreateTriggerSkill{
  name = "emo__lunshi",
  events = {fk.TurnStart},
  anim_type = "control",
  frequency = Skill.Compulsory,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skills = table.filter(lunshi_skills, function (s)
      s = Fk.skills[s]
      return s and s:isInstanceOf(ActiveSkill) and not player:hasSkill(s, true)
    end)
    if #skills == 0 then return end
    local skill = table.random(skills)
    room:handleAddLoseSkills(player, skill)
    room:setPlayerMark(player, "@emo__lunshi", skill)
  end,
}

local emo__lunshi_delay = fk.CreateTriggerSkill{
  name = "#emo__lunshi_delay",
  events = {fk.TurnEnd, fk.PindianFinished},
  mute = true,
  priority = 0.99, -- 诶嘿
  frequency = Skill.Compulsory,
  can_trigger = function (self, event, target, player, data)
    if event == fk.TurnEnd then
      return target == player and player:getMark("@emo__lunshi") ~= 0
    else
      return player:hasSkill(emo__lunshi) and player:getMark("@emo__lunshi") == data.reason
      and player:getMark("emo__lunshi_used-turn") == 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skillName = "emo__lunshi"
    local skill = player:getMark("@emo__lunshi")
    if event == fk.TurnEnd then
      room:handleAddLoseSkills(player, "-"..skill)
      room:setPlayerMark(player, "@emo__lunshi", 0)
    else
      room:setPlayerMark(player, "emo__lunshi_used-turn", 1)
      local win
      for _, result in pairs(data.results) do
        if result.winner == player then
          win = true
          break
        end
      end
      if win then
        player:drawCards(1, skillName)
        player:setSkillUseHistory(data.reason, 0, Player.HistoryTurn)
        player:setSkillUseHistory(data.reason, 0, Player.HistoryPhase)
      else
        room:setPlayerMark(player, "@emo__lunshi", 0)
        room:handleAddLoseSkills(player, "-"..data.reason)
        local skills = table.filter(lunshi_skills, function (s)
          s = Fk.skills[s]
          return s and s:isInstanceOf(ActiveSkill) and not player:hasSkill(s, true)
          and player:usedSkillTimes(s.name, Player.HistoryPhase) == 0
        end)
        table.removeOne(skills, data.reason)
        if #skills == 0 then return end
        skill = table.random(skills)
        room:setPlayerMark(player, "@emo__lunshi", skill)
        room:handleAddLoseSkills(player, skill)
      end
    end
  end,
}
emo__lunshi:addRelatedSkill(emo__lunshi_delay)
moe__mofei:addSkill(emo__lunshi)

local emo__danshe = fk.CreateTriggerSkill{
  name = "emo__danshe",
  anim_type = "control",
  events = {fk.PindianCardsDisplayed},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 then
      return not player:isKongcheng()
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local num = #room.alive_players
    local playerMap = table.map(data.tos, function (p) return {p, data.results[p.id].toCard} end)
    table.insert(playerMap, 1, {data.from, data.fromCard})
    for _, dat in ipairs(playerMap) do
      local p = dat[1]
      local card = dat[2]
      if room:getCardArea(card:getEffectiveId()) == Card.Processing and p ~= player then
        local ids = table.filter(player:getCardIds("h"), function(id) return math.abs(Fk:getCardById(id).number - card.number) <= num end)
        local chosen = room:askForCard(player, 1, 1, false, self.name, true, tostring(Exppattern{ id = ids }), 
        "#emo__danshe-card::"..p.id..":"..num..":"..card:toLogString())
        if #chosen > 0 then
          self.cost_data = {p, chosen}
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = self.cost_data[1]
    local chosen = self.cost_data[2]
    local chosenCard = Fk:getCardById(chosen[1])
    local pindianCard = chosenCard:clone(chosenCard.suit, chosenCard.number)
    pindianCard:addSubcard(chosenCard.id)
    local moves = {}
    local get = {}
    local orig = ""
    if to == data.from then
      get = data.fromCard.subcards
      orig = data.fromCard:toLogString()
      data.fromCard = pindianCard
    else
      get = data.results[to.id].toCard.subcards
      orig = data.results[to.id].toCard:toLogString()
      data.results[to.id].toCard = pindianCard
    end
    room:sendLog{
      type = "#EmoDansheReplace",
      from = to.id,
      arg = orig,
      arg2 = chosenCard:toLogString()
    }
    room:moveCards({
      ids = get,
      fromArea = Card.Processing,
      toArea = Card.PlayerHand,
      to = player.id,
      moveReason = fk.ReasonPrey,
      skillName = self.name,
      proposer = player.id,
    },{
      ids = chosen,
      fromArea = Card.PlayerHand,
      from = player.id,
      toArea = Card.Processing,
      moveReason = fk.ReasonPut,
      skillName = self.name,
      proposer = player.id,
    })
  end,
}

moe__mofei:addSkill(emo__danshe)

Fk:loadTranslationTable{
  ["moe__mofei"] = "莫菲",
  
  ["emo__lunshi"] = "论势",
  [":emo__lunshi"] = "锁定技，回合开始时，你从三个拼点技能中选择一个于本回合获得（固定技能池）。本回合你首次因此技能拼点后，若你赢，摸一张牌并视为未发动之；没赢，你更换因〖论势〗获得的技能。",
  ["#emo__lunshi_delay"] = "论势",
  ["#emo__lunshi-choice"] = "论势：选择一个拼点技能，于本回合获得",
  ["@emo__lunshi"] = "论势",

  ["emo__danshe"] = "胆慑",
  [":emo__danshe"] = "每回合一次，当一名其他角色的拼点牌展示时，你可以用一张与之点数差不大于X的手牌替换之（X为存活角色数）。",
  ["#emo__danshe-card"] = "胆慑：你可以用一张点数差不大于%arg的手牌替换%dest的拼点牌%arg2",
  ["#EmoDansheReplace"] = "%from 的拼点牌%arg被替换为%arg2",
}

local moe__annie = General(extension, "moe__annie", "moe", 3, 3, General.Female)

local canDuling = function(to)
  return to:getHandcardNum() > to.hp and not to:isKongcheng() and not to.dead and to:getMark("@emo__duling") > 0
end

local checkDulingEffect = function (room, to)
  while canDuling(to) do
    room:removePlayerMark(to, "@emo__duling")
    local id = table.random(to:getCardIds("h"))
    room:throwCard({id}, "emo__duling", to, to)
  end
end

local emo__duling = fk.CreateTriggerSkill{
  name = "emo__duling",
  anim_type = "masochism",
  events = { fk.Damaged },
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1, "#emo__duling-target", self.name, true)
    if #tos > 0 then
      self.cost_data = tos[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    room:addPlayerMark(to, "@emo__duling", 5)
    checkDulingEffect(room, to)
  end,
}

local emo__duling_negated = fk.CreateTriggerSkill{
  name = "#emo__duling_negated",
  anim_type = "negative",
  events = { fk.DamageInflicted , fk.HpChanged, fk.AfterCardsMove },
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.DamageInflicted then
      return target:getMark("@emo__duling") > 0 and data.card and data.card.color == Card.Red
    else
      local tos = {}
      if event == fk.HpChanged then 
        if canDuling(target) then
          table.insert(tos, target.id)
        end
      else
        for _, move in ipairs(data) do
          if move.to and canDuling(player.room:getPlayerById(move.to)) then table.insertIfNeed(tos, move.to) end
          if move.from and canDuling(player.room:getPlayerById(move.from)) then table.insertIfNeed(tos, move.from) end
        end
      end
      if #tos > 0 then
        self.cost_data = tos
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageInflicted then
      data.damage = data.damage + 1
    else
      for _, to in ipairs(table.map(self.cost_data, Util.Id2PlayerMapper)) do
        checkDulingEffect(room, to)
      end
    end
  end,

  refresh_events = {fk.EventLoseSkill, fk.Deathed},
  can_refresh = function(self, event, target, player, data)
    if table.find(player.room.alive_players, function(p) return p:hasSkill(self, true) end) then return false end
    if event == fk.EventLoseSkill then
      return data == self and target == player
    else
      return target == player and player:hasSkill(self, true, true)
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    table.forEach(room.alive_players, function(p) room:setPlayerMark(p, "@emo__duling", 0) end)
  end,
}

emo__duling:addRelatedSkill(emo__duling_negated)

moe__annie:addSkill(emo__duling)

local emo__yue = fk.CreateTriggerSkill{
  name = "emo__yue",
  anim_type = "control",
  events = {fk.EventPhaseStart, fk.Death},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      if player:hasSkill(self) and target == player and player.phase == Player.Play then
        local mark = type(player:getMark(self.name)) == "table" and player:getMark(self.name) or {}
        for _, id in ipairs(player.room.discard_pile) do
          local card = Fk:getCardById(id, true)
          if (card.name == "dismantlement" or card.name == "snatch") and not table.contains(mark, id) then
            self.cost_data = id
            return true
          end
        end
      end
    else
      return player:hasSkill(self, false, true) and target == player
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      local id = self.cost_data
      local mark = type(player:getMark(self.name)) == "table" and player:getMark(self.name) or {}
      table.insert(mark, id)
      room:setPlayerMark(player, self.name, mark)
      room:obtainCard(player, id, true, fk.ReasonPrey, player.id, self.name)
    else
      local targets = table.map(room:getOtherPlayers(player), Util.IdMapper)
      if #targets == 0 then return end
      local tos = room:askForChoosePlayers(player, targets, 1, 1, "#emo__yue-choose", self.name, false)
      local to = room:getPlayerById(tos[1])
      room:handleAddLoseSkills(to, self.name, nil)
    end
  end,
}
moe__annie:addSkill(emo__yue)

Fk:loadTranslationTable{
  ["moe__annie"] = "安涅",
  
  ["emo__duling"] = "渎灵",
  [":emo__duling"] = "每当你受到伤害后，你可以令一名其他角色获得5枚“渎”标记。拥有“渎”标记的角色：受到红色牌造成的伤害+1，每当其手牌数大于体力值时，弃1枚“渎”标记并随机弃置一张手牌。",
  ["@emo__duling"] = "渎",
  ["#emo__duling_negated"] = "渎灵",
  ["#emo__duling-target"] = "渎灵：可令一名其他角色获得“渎”标记，当其手牌数大于体力值时随机弃手牌",

  ["emo__yue"] = "余恶",
  [":emo__yue"] = "锁定技，出牌阶段开始时，你获得弃牌堆随机一张你未以此法获得过的【过河拆桥】或【顺手牵羊】。你死亡时，你须令一名其他角色获得此技能。",
  ["#emo__yue-choose"] = "余恶：令一名其他角色获得“余恶”",
}

local moe__buzhiniao = General(extension, "moe__buzhiniao", "moe", 4, 4, General.Female)

local emo__wuji = fk.CreateTriggerSkill{
  name = "emo__wuji",
  anim_type = "offensive",
  events = {fk.DamageCaused, fk.Damage},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and data.card and data.card.trueName == "slash" then
      if event == fk.DamageCaused then
        return #player:getCardIds("e") > 0
      else
        return player:isWounded() and not player:isKongcheng()
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageCaused then
      local throw = room:askForDiscard(player, 1, 1, true, self.name, true, ".|.|.|equip", "#emo__wuji-discard::"..data.to.id)
      if #throw > 0 then
        self.cost_data = throw
        return true
      end
    else
      local cardIds = {}
      for _, cid in ipairs(player:getCardIds("h")) do
        local card = Fk:getCardById(cid)
        if card.type == Card.TypeEquip and player:canUseTo(card, player) then
          table.insert(cardIds, cid)
        end
      end
      if #cardIds > 0 then
        local card = room:askForCard(player, 1, 1, false, self.name, true, tostring(Exppattern{ id = cardIds }), "#emo__wuji-use")
        if card then
          self.cost_data = card[1]
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageCaused then
      room:throwCard(self.cost_data, self.name, player, player)
      data.damage = data.damage + 1
    else
      room:useCard{from = player.id, tos = {{player.id}}, card = Fk:getCardById(self.cost_data)}
      if not player.dead and player:isWounded() then
        room:recover({ who = player,  num = 1, skillName = self.name })
      end
    end
  end,
}
moe__buzhiniao:addSkill(emo__wuji)

local emo__weiming = fk.CreateTriggerSkill{
  name = "emo__weiming",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.phase == Player.Start and player:isWounded() and player:getMark("emo__weiming-turn") == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = room:askForUseCard(player, "slash", "slash", "#emo__weiming", true, {bypass_times = true})
    if use then
      use.extraUse = true
      room:useCard(use)
      if player.dead then return false end
      player:drawCards(1, self.name)
    else
      room:loseHp(player, 1, self.name)
      if player.dead then return false end
      player:drawCards(2, self.name)
    end
    if player.dead or not (use and use.damageDealt) then
      room:setPlayerMark(player, "@@emo__weiming", 1)
    end
  end,

  refresh_events = {fk.TurnStart},
  can_refresh = function (self, event, target, player, data)
    return player:getMark("@@emo__weiming") > 0 
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(player, "@@emo__weiming", 0)
    player.room:setPlayerMark(player, "emo__weiming-turn", 1)
  end,
}
moe__buzhiniao:addSkill(emo__weiming)


Fk:loadTranslationTable{
  ["moe__buzhiniao"] = "不知鸟",
  
  ["emo__wuji"] = "武姬",
  [":emo__wuji"] = "每当你使用【杀】造成伤害时，你可以弃置装备区一张牌令此伤害+1。每当你使用【杀】造成伤害后，若你已受伤，你可以使用手牌中一张装备牌并回复1点体力。",
  ["#emo__wuji-discard"] = "武姬：你可弃置装备区一张牌，令此【杀】对%dest的伤害+1",
  ["#emo__wuji-use"] = "武姬：你可使用手牌中一张装备牌，回复1点体力",

  ["emo__weiming"] = "危鸣",
  [":emo__weiming"] = "锁定技，一名角色的准备阶段开始时，若你已受伤，你须选择一项：1.使用一张【杀】，摸一张牌；2.失去一点体力，摸两张牌。若你未以此法造成伤害，〖危鸣〗下回合失效。",
  ["#emo__weiming"] = "危鸣：使用一张【杀】然后摸一张牌，否则失去一点体力并摸两张牌",
  ["@@emo__weiming"] = "危鸣失效",
}

local moe__liuhua = General(extension, "moe__liuhua", "moe", 3, 3, General.Female)

local emo__qingyang = fk.CreateTriggerSkill{
  name = "emo__qingyang",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player.phase == Player.Play
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local names = {}
    for name, card in pairs(Fk.all_card_types) do
      if card.package.name == "standard_cards" then
        table.insert(names, name)
      end
    end
    local cards = {}
    for _, id in ipairs(room.draw_pile) do
      local card = Fk:getCardById(id)
      if table.contains(names, card.name) and not cards[1] then
        cards[1] = id
      end
      if not table.contains(names, card.name) and not cards[2] then
        cards[2] = id
      end
      if #cards == 2 then break end
    end
    if #cards > 0 then
      room:moveCardTo(cards, Player.Hand, player, fk.ReasonPrey, self.name)
    end
  end,
}
moe__liuhua:addSkill(emo__qingyang)

local emo__fushan = fk.CreateTriggerSkill{
  name = "emo__fushan",
  anim_type = "defensive",
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.damage > 1 and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askForDiscard(player, 1, 1, true, self.name, true, ".", 
    "#emo__fushan-invoke::"..target.id..":"..data.damage, true)
    if #cards > 0 then
      self.cost_data = {cards = cards, tos = {target.id}}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(self.cost_data.cards, self.name, player, player)
    if not player.dead then
      room:damage { to = player, damage = 1, skillName = self.name }
    end
    return true
  end,
}
moe__liuhua:addSkill(emo__fushan)

local emo__youwu = fk.CreateTriggerSkill{
  name = "emo__youwu",
  anim_type = "masochism",
  events = {fk.Damaged},
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function(p) return not p:isAllNude() end)
    if #targets > 0 then
      local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__youwu-choose", self.name, true)
      if #tos > 0 then
        self.cost_data = {tos = tos}
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    local chosen = room:askForCardChosen(player, to, "hej", self.name)
    local area = room:getCardArea(chosen)
    room:throwCard({chosen}, self.name, to, player)
    if player.dead or to.dead or room:getCardArea(chosen) ~= Card.DiscardPile then return end
    if #table.filter(to:getCardIds(area), function(id) return Fk:getCardById(id).color == Card.Red end) == 
    #table.filter(to:getCardIds(area), function(id) return Fk:getCardById(id).color == Card.Black end) then
      local targets = table.filter(room.alive_players, function(p) 
        return (to:distanceTo(p) == 1 or to == p) and not table.contains(to.sealedSlots, Player.JudgeSlot) 
        and not to:hasDelayedTrick("supply_shortage") 
      end)
      if #targets == 0 then return end
      local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__youwu-put::"..to.id, self.name, true)
      if #tos > 0 then
        to = room:getPlayerById(tos[1])
        local card = Fk:cloneCard("supply_shortage")
        card:addSubcard(chosen)
        to:addVirtualEquip(card)
        room:moveCardTo(card, Player.Judge, to, fk.ReasonPut, self.name, nil, true, player.id) 
      end
    end
  end,
}
moe__liuhua:addSkill(emo__youwu)

Fk:loadTranslationTable{
  ["moe__liuhua"] = "流华",
  
  ["emo__qingyang"] = "轻扬",
  [":emo__qingyang"] = "出牌阶段开始时，你可以摸来自标准包和非标准包各一张牌。",
  
  ["emo__fushan"] = "抚扇",
  [":emo__fushan"] = "每当一名角色受到大于1点伤害时，你可以弃置一张牌防止之，然后你受到1点无来源伤害。",
  ["#emo__fushan-invoke"] = "抚扇：你可弃一张牌，防止 %dest 受到的 %arg点伤害，然后你受到1点伤害",

  ["emo__youwu"] = "幽舞",
  [":emo__youwu"] = "每当你受到伤害后，你可以弃置一名角色区域内一张牌，然后若该角色此区域的红色牌与黑色牌数量相等，你可将弃置的牌当【兵粮寸断】置于其距离1以内一名角色的判定区。",
  ["#emo__youwu-choose"] = "幽舞：你可以弃置一名角色区域内的一张牌",
  ["#emo__youwu-put"] = "幽舞：你可将此牌当【兵粮寸断】置于 %dest 距离1以内角色的判定区",
}

local moe__changming = General(extension, "moe__changming", "moe", 4, 4, General.Female)

local emo__juetou = fk.CreateTriggerSkill{
  name = "emo__juetou",
  anim_type = "offensive",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and data.card.trueName == "slash" then
      local list = data.damageDealt or {}
      return table.find(player.room:getOtherPlayers(player), function(p) return not p:isNude() and (list[p.id] == nil) end)
    end
  end,
  on_cost =function (self, event, target, player, data)
    local room = player.room
    local list = data.damageDealt or {}
    local targets = table.filter(room:getOtherPlayers(player), function(p) return not p:isNude() and (list[p.id] == nil) end)
    if #targets == 0 then return end
    local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__juetou-choose", self.name, true)
    if #tos > 0 then
      self.cost_data = tos[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    if to:isNude() then return end
    local cards = room:askForCard(to, 1, 1, true, self.name, false, ".", "#emo__juetou-give:"..player.id)
    room:moveCardTo(cards, Player.Hand, player, fk.ReasonGive, self.name, nil, true, to.id)
    local card = Fk:getCardById(cards[1])
    if card.sub_type == Card.SubtypeWeapon or card.trueName == "slash" then
      room:addPlayerMark(player, MarkEnum.SlashResidue.."-phase")
      if not data.damageDealt then return end
      local list = data.damageDealt
      for _, p in ipairs(room:getAlivePlayers()) do
        if list[p.id] and not p.dead then
          room:loseHp(p, 1, self.name)
        end
      end
    end
  end,
}

moe__changming:addSkill(emo__juetou)

local emo__chejing = fk.CreateTriggerSkill{
  name = "emo__chejing",
  events = {fk.EventPhaseChanging},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and not player:isKongcheng() then
      return (data.to == Player.Judge and #player:getCardIds("j") > 0)
      or (data.to == Player.Discard and player:getHandcardNum() > player:getMaxCards())
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:showCards(player:getCardIds("h"))
    return true
  end,
}

moe__changming:addSkill(emo__chejing)

Fk:loadTranslationTable{
  ["moe__changming"] = "长明",
  
  ["emo__juetou"] = "绝透",
  [":emo__juetou"] = "每当你使用的【杀】结算后，你可以令未受到此【杀】伤害的一名其他角色交给你一张牌，若交给你的牌为【杀】或武器牌：令受到此【杀】伤害的角色依次失去一点体力，且本阶段你使用【杀】次数上限+1。",
  ["#emo__juetou-choose"] = "绝透：你可以令未受到此【杀】伤害的一名其他角色交给你一张牌",
  ["#emo__juetou-give"] = "绝透：交给%src一张牌，若为【杀】或武器牌，受到其【杀】伤害的角色依次失去一点体力",

  ["emo__chejing"] = "彻净",
  [":emo__chejing"] = "若你判定区有牌/手牌数大于手牌上限，你可以展示所有手牌，跳过判定/弃牌阶段。",
}

local moe__chuya = General(extension, "moe__chuya", "moe", 4, 4, General.Female)

local emo__xinya = fk.CreateViewAsSkill{
  name = "emo__xinya",
  pattern = "analeptic",
  card_num = 0,
  card_filter = Util.FalseFunc,
  prompt = "#emo__xinya-prompt",
  before_use = function(self, player, use)
    local room = player.room
    room:changeMaxHp(player, -1)
    use.extraUse = true
  end,
  view_as = function(self, cards)
    local c = Fk:cloneCard("analeptic")
    c.skillName = self.name
    return c
  end,
  enabled_at_response = function (self, player, response)
    return not response
  end,
}

local emo__xinya_targetmod = fk.CreateTargetModSkill{
  name = "#emo__xinya_targetmod",
  bypass_times = function(self, player, skill, scope, card)
    return card and table.contains(card.skillNames, "emo__xinya")
  end,
}
emo__xinya:addRelatedSkill(emo__xinya_targetmod)

local emo__xinya_trigger = fk.CreateTriggerSkill{
  name = "#emo__xinya_trigger",
  anim_type = "support",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return target == player and table.contains(data.card.skillNames, "emo__xinya") and player:hasSkill("emo__xinya") and player.maxHp == 1
  end,
  on_cost = function(self, event, target, player, data)
    local tos = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#emo__xinya-choose", self.name, true)
    if #tos > 0 then
      self.cost_data = tos[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    room:handleAddLoseSkills(player, "-emo__xinya", nil)
    room:handleAddLoseSkills(to, "emo__xinya", nil)
  end,
}
emo__xinya:addRelatedSkill(emo__xinya_trigger)
moe__chuya:addSkill(emo__xinya)

local emo__mengbi = fk.CreateTriggerSkill{
  name = "emo__mengbi",
  anim_type = "support",
  events = {fk.TargetConfirmed},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card.trueName == "slash" and not target:isWounded()
  end,
  on_cost = function (self, event, target, player, data)
    local x = math.max(1, target.maxHp - target:getHandcardNum())
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__mengbi-invoke:"..target.id.."::"..x)
  end,
  on_use = function(self, event, target, player, data)
    local x = math.max(1, target.maxHp - target:getHandcardNum())
    player.room:doIndicate(player.id, {target.id})
    target:drawCards(x, self.name)
  end,
}
moe__chuya:addSkill(emo__mengbi)

Fk:loadTranslationTable{
  ["moe__chuya"] = "初芽",
  
  ["emo__xinya"] = "新芽",
  [":emo__xinya"] = "每当你需要使用【酒】时，你可以扣减1点体力上限，视为使用了一张无次数限制的【酒】，然后若你体力上限为1，你可以失去〖新芽〗并令一名其他角色获得之。",
  ["#emo__xinya_trigger"] = "新芽",
  ["#emo__xinya-prompt"] = "新芽：你可以扣减1点体力上限，视为使用【酒】",
  ["#emo__xinya-choose"] = "新芽：你可以失去〖新芽〗并令一名其他角色获得之",

  ["emo__mengbi"] = "萌庇",
  [":emo__mengbi"] = "每当一名未受伤的角色成为【杀】目标后，你可以令其摸X张牌（X为其体力上限减手牌数，且至少为1）。",
  ["#emo__mengbi-invoke"] = "萌庇：你可以令 %src 摸 %arg 张牌",
}

local moe__qinghe = General(extension, "moe__qinghe", "moe", 4, 4, General.Female)

local emo__jianying = fk.CreateTriggerSkill{
  name = "emo__jianying",
  events = {fk.GameStart , fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    if event == fk.GameStart then
      return player:hasSkill(self)
    else
      return player:hasSkill(self) and data.card and data.card.trueName == "slash" and target:getEquipment(Card.SubtypeWeapon)
      and player.room.logic:damageByCardEffect()
    end
  end,
  on_cost = function (self, event, target, player, data)
    local prompt = (event == fk.GameStart) and "#emo__jianying-invoke" or "#emo__jianying-damage:"..target.id..":"..data.to.id
    return player.room:askForSkillInvoke(player, self.name, nil, prompt)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart then
      for _, p in ipairs(room:getAlivePlayers()) do
        if not p.dead then
          for i = 1, #room.draw_pile, 1 do
            local card = Fk:getCardById(room.draw_pile[i])
            if card.sub_type == Card.SubtypeWeapon and p:canUseTo(card, p) then
              room:useCard{ from = p.id, card = card, tos = {{p.id}}, }
              break
            end
          end
        end
      end
    else
      room:throwCard(target:getEquipments(Card.SubtypeWeapon), self.name, target, player)
      data.damage = data.damage + 1
      if not player.dead then
        player:drawCards(1, self.name)
      end
    end
  end,
}
moe__qinghe:addSkill(emo__jianying)

local emo__jinglue = fk.CreateActiveSkill{
  name = "emo__jinglue",
  anim_type = "offensive",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 1,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and Self.id ~= to_select and not Fk:currentRoom():getPlayerById(to_select):isNude()
  end,
  prompt = "#emo__jinglue-prompt",
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    local id = room:askForCardChosen(player, to, "he", self.name)
    room:obtainCard(player, id, false, fk.ReasonPrey)
    local lose = Fk:getCardById(id, true).name == "jink"
    if not to.dead and not player.dead then
      local slash = Fk:cloneCard("slash")
      slash.skillName = self.name
      if not player:prohibitUse(slash) and not player:isProhibited(to, slash) then
        local use = {from = player.id, tos = {{to.id}}, card = slash, extraUse = true}
        room:useCard(use)
        lose = lose or (use.damageDealt == nil)
      end
    end
    if not player.dead and lose then
      player:setSkillUseHistory(self.name, 0, Player.HistoryPhase)
      room:loseHp(player, 1, self.name)
    end
  end,
}
moe__qinghe:addSkill(emo__jinglue)

Fk:loadTranslationTable{
  ["moe__qinghe"] = "青禾",
  
  ["emo__jianying"] = "剑影",
  [":emo__jianying"] = "①游戏开始时，你可以令每名角色随机使用牌堆中一张武器牌。②每当一名角色使用【杀】对目标角色造成伤害时，你可以弃置其装备区的武器牌令此伤害+1，然后你摸一张牌。",
  ["#emo__jianying-damage"] = "剑影：你可弃置 %src 的武器牌，令其对 %dest 造成伤害+1，然后你摸一张牌",
  ["#emo__jianying-invoke"] = "剑影:你可以令每名角色随机使用牌堆中一张武器牌",

  ["emo__jinglue"] = "惊掠",
  [":emo__jinglue"] = "出牌阶段限一次，你可以获得一名其他角色的一张牌，视为对其使用一张不计入次数的【杀】，若你以此法获得了【闪】或此【杀】未造成伤害，你失去一点体力且〖惊掠〗视为未发动。",
  ["#emo__jinglue-prompt"] = "惊掠：获得一名其他角色的一张牌，视为对其使用【杀】",
}

local moe__rie = General(extension, "moe__rie", "moe", 3, 3, General.Female)

local emo__jieyun = fk.CreateTriggerSkill{
  name = "emo__jieyun",
  anim_type = "support",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return not player:isKongcheng() and player:hasSkill(self) and not target.dead
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__jieyun-invoke:"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {  who = target, reason = self.name, pattern = "." }
    room:judge(judge)
    if player:isKongcheng() then return false end
    local n = math.ceil(#Fk:translate(judge.card.trueName)/3)
    local cards = room:askForCard(player, 1, 1, false, self.name, false, ".", "#emo__jieyun-show::"..target.id..":"..n)
    player:showCards(cards)
    local card = Fk:getCardById(cards[1])
    local num = math.abs(n-#Fk:translate(card.trueName)/3)
    if num > 0 then
      target:drawCards(num, self.name)
      if num >= math.random(5) then
        room:damage { to = player, damage = 1, skillName = self.name }
      end
    end
  end,
}
moe__rie:addSkill(emo__jieyun)

local emo__chuanyin = fk.CreateTriggerSkill{
  name = "emo__chuanyin",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if target.phase == Player.Finish and player:hasSkill(self) and not player:isKongcheng() then
      return player == target or #player.room.logic:getActualDamageEvents(1, function(e) return e.data[1].to == player end) > 0
    end
  end,
  on_cost = function (self, event, target, player, data)
    local tos, cards = player.room:askForChooseCardsAndPlayers(player, 1, 3, table.map(player.room.alive_players, Util.IdMapper), 
    1, 1, ".|.|.|hand", "#emo__chuanyin-put", self.name, true)
    if #tos > 0 and #cards > 0 then
      self.cost_data = {tos = tos, cards = cards}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:getPlayerById(self.cost_data.tos[1]):addToPile("emo__chuanyin&", self.cost_data.cards, false, self.name)
  end,
}

local emo__chuanyin_delay = fk.CreateTriggerSkill{
  name = "#emo__chuanyin_delay",
  anim_type = "defensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and target.phase == Player.Start and target:isWounded() 
    and #player:getPile("emo__chuanyin&") >= math.max(1, player.hp)
  end,
  on_cost = function (self, event, target, player, data)
    local x = math.max(1, player.hp)
    local cards = player.room:askForCard(player, x, x, false, "emo__chuanyin", true, ".|.|.|emo__chuanyin&", 
    "#emo__chuanyin-cost:::"..x, "emo__chuanyin&")
    if #cards == x then
      self.cost_data = cards
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:moveCards({
      from = player.id,
      ids = self.cost_data,
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonPutIntoDiscardPile,
      skillName = "emo__chuanyin",
    })
    if not player.dead and player:isWounded() then
      room:recover { num = 1, skillName = "emo__chuanyin", who = player , recoverBy = player }
    end
  end,
}
emo__chuanyin:addRelatedSkill(emo__chuanyin_delay)
moe__rie:addSkill(emo__chuanyin)

Fk:loadTranslationTable{
  ["moe__rie"] = "理惠",
  ["#moe__rie"] = "流浪商人",
  
  ["emo__jieyun"] = "解运",
  [":emo__jieyun"] = "每当一名角色受到伤害后，若你有手牌，你可以令其进行一次判定，若如此做，你展示一张手牌并令其摸X张牌（X为此牌与判定牌牌名字数之差），然后你有20X%（至多为100%）概率受到1点伤害。",
  ["#emo__jieyun-invoke"] = "解运：你可以令 %src 判定，并展示手牌令其摸牌",
  ["#emo__jieyun-show"] = "解运：请展示一张手牌，令%dest摸X张牌（X为你展示牌的牌名字数与%arg之差）",

  ["emo__chuanyin"] = "传音",
  [":emo__chuanyin"] = "你的回合或你受到伤害的回合的结束阶段，你可以将至多三张手牌扣置一名角色武将牌旁称为“传音”牌，其可以将这些牌如手牌般使用或打出。其准备阶段可以将X张“传音”牌置入弃牌堆并回复1点体力（X为其体力值且至少为1）。",
  ["emo__chuanyin&"] = "传音",
  ["#emo__chuanyin_delay"] = "传音",
  ["#emo__chuanyin-cost"] = "传音：可以将 %arg 张“传音”牌置入弃牌堆并回复1点体力",
  ["#emo__chuanyin-put"] = "传音:将至多三张手牌扣置一名角色武将牌旁，其可以如手牌般使用或打出",
}

local moe__yoshiwara = General(extension, "moe__yoshiwara", "moe", 3, 3, General.Female)

local emo__miluan = fk.CreateTriggerSkill{
  name = "emo__miluan",
  anim_type = "control",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and target.phase == Player.Play and not target:isKongcheng()
  end,
  on_cost = function (self, event, target, player, data)
    self.cost_data = {tos = {target.id}}
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__miluan-invoke:"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cardId = table.random(target:getCardIds("h"))
    target:showCards({cardId})
    local card = Fk:getCardById(cardId)
    if (card:isCommonTrick() or card.type == Card.TypeBasic) and not target:prohibitUse(card) then
      if card.skill:getMinTargetNum() < 2 then
        local tos = table.filter(room.alive_players, function (p)
          return target:canUseTo(card, p)
        end)
        if #tos > 0 then
          room:delay(800)
          tos = table.random(tos, 2)
          room:useCard({
            from = target.id,
            tos = table.map(tos, function(p) return {p.id} end),
            card = card,
          })
          return false
        end
      end
    end
    room:obtainCard(player, cardId, true, fk.ReasonPrey, player.id, self.name)
  end,
}
moe__yoshiwara:addSkill(emo__miluan)


local emo__huafu = fk.CreateTriggerSkill{
  name = "emo__huafu",
  events = {fk.TargetConfirmed},
  frequency = Skill.Compulsory,
  anim_type = "defensive",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(self) and target == player and data.from and data.from ~= player then
      for _, id in ipairs(player.room:getPlayerById(data.from):getCardIds("e")) do
        if #player:getEquipments(Fk:getCardById(id).sub_type) == 0 then
          local ids = player.room:getCardsFromPileByRule(".|.|.|.|.|"..Fk:getCardById(id):getSubtypeString())
          if #ids > 0 then
            self.cost_data = ids[1]
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = Fk:getCardById(self.cost_data)
    local slot = Util.convertSubtypeAndEquipSlot(card.sub_type)
    if table.contains(player.sealedSlots, slot) then
      room:resumePlayerArea(player, slot)
    end
    room:moveCardIntoEquip(player, card.id, self.name, true, player)
  end,
}

local emo__huafu_maxcards = fk.CreateMaxCardsSkill{
  name = "#emo__huafu_maxcards",
  correct_func = function(self, player)
    if player:hasSkill(emo__huafu) then
      return #player:getCardIds("e")
    end
  end,
}
emo__huafu:addRelatedSkill(emo__huafu_maxcards)

moe__yoshiwara:addSkill(emo__huafu)


Fk:loadTranslationTable{
  ["moe__yoshiwara"] = "吉原",
  
  ["emo__miluan"] = "迷乱",
  [":emo__miluan"] = "其他角色的出牌阶段开始时，你可以展示一张手牌，若为其可使用的基本牌或普通锦囊牌，令其对随机两个合法目标使用之，否则你获得此牌。",
  ["#emo__miluan-invoke"] = "迷乱：你可以展示 %src 的一张手牌，令其使用此牌或你获得之",

  ["emo__huafu"] = "华服",
  [":emo__huafu"] = "锁定技，每当你成为其他角色牌的目标后，若其装备区有你未装备的副类型的装备，则你从牌堆或弃牌堆随机将一张此类装备置入装备区（若此装备栏已废除，先恢复之）。你装备区每有一张牌，手牌上限+1。",
}

local moe__wangyue = General(extension, "moe__wangyue", "moe", 3, 3, General.Female)

-- 更新择道标记显示
local updataZedaoMark = function (player)
  local room = player.room
  local mark = player:getTableMark("emo__zedao")
  local str = ""
  if #mark == 0 then
    room:setPlayerMark(player, "@emo__zedao", 0)
    return
  end
  for i = 1, 3 do
    local m = mark[i]
    if m ~= "x" then
      -- 带下划线前缀表示此项已被改变过
      local red = m:startsWith("_")
      if red then m = string.sub(m, 2) end
      m = Fk:translate("log_"..m)
      if red then m = '<font color="#FF3333">'..m..'</font>' end
    end
    if i ~= 1 then m = "-"..m end
    str = str..m
  end
  room:setPlayerMark(player, "@emo__zedao", str)
end

-- 执行择道内容
local doZedao = function (player, to, index, force)
  local room = player.room
  local skillName = "emo__zedao"
  local mark = player:getTableMark(skillName)
  if index == 1 then
    local m = mark[1]
    if m:endsWith("1") then
      player:drawCards(1, skillName)
    elseif not to:isNude() then
      local cid = room:askForCardChosen(player, to, "he", skillName)
      room:doIndicate(player.id, {to.id})
      room:throwCard({cid}, skillName, to, player)
    end
  elseif index == 2 then
    local m = mark[2]
    local cardType = m:endsWith("1") and "trick" or "basic"
    local ids = room:getCardsFromPileByRule(".|.|.|.|.|"..cardType)
    if #ids > 0 then
      room:obtainCard(to, ids[1], false, fk.ReasonJustMove)
    end
  elseif index == 3 then
    local m = mark[3]
    if m:endsWith("1") then
      if force or room:askForSkillInvoke(player, skillName, nil, "#emo__zedao-recover:"..to.id) then
        room:doIndicate(player.id, {to.id})
        room:recover { num = 1, skillName = skillName, who = to, recoverBy = player }
      end
    else
      if force or room:askForSkillInvoke(player, skillName, nil, "#emo__zedao-damage:"..to.id) then
        room:doIndicate(player.id, {to.id})
        room:damage { from = player, to = to, damage = 1, skillName = skillName }
      end
    end
  end
end

local emo__zedao = fk.CreateTriggerSkill{
  name = "emo__zedao",
  events = {fk.GameStart, fk.TargetSpecified, fk.Damaged, fk.EnterDying},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.GameStart then return true end
    local mark = player:getTableMark("emo__zedao")
    if not player.dead and #mark > 0 then
      if event == fk.TargetSpecified then
        return target == player and data.card.trueName == "slash" and mark[1] ~= "x"
      elseif event == fk.Damaged then
        return target == player and mark[2] ~= "x"
      else
        if mark[3] ~= "x" then
          local events = player.room.logic:getEventsOfScope(GameEvent.Dying, 1, function(e)
            local dying = e.data[1]
            return dying.who == target.id
          end, Player.HistoryGame)
          return #events == 1 and events[1].data[1] == data
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart then
      local choices = {}
      for i = 1, 3 do
        local choice = room:askForChoice(player, {"emo__zedao_"..i.."_1", "emo__zedao_"..i.."_2"}, self.name, "#emo__zedao-choice"..i)
        table.insert(choices, choice)
      end
      room:setPlayerMark(player, self.name, choices)
      updataZedaoMark(player)
    else
      local skillName = "emo__zedao"
      local mark = player:getTableMark(skillName)
      if event == fk.TargetSpecified then
        local to = room:getPlayerById(data.to)
        doZedao(player, to, 1)
      elseif event == fk.Damaged then
        doZedao(player, player, 2)
      else
        doZedao(player, target, 3)
      end
    end
  end,

  on_lose = function (self, player)
    player.room:setPlayerMark(player, "emo__zedao", 0)
    player.room:setPlayerMark(player, "@emo__zedao", 0)
  end,
}
moe__wangyue:addSkill(emo__zedao)

local emo__shunshi = fk.CreateActiveSkill{
  name = "emo__shunshi",
  card_num = 0,
  target_num = 1,
  interaction = function()
    local choices = {}
    local mark = Self:getTableMark("emo__zedao")
    for _, m in ipairs(mark) do
      if m ~= "x" then
        if m:startsWith("_") then m = string.sub(m, 2) end
        table.insert(choices, m)
      end
    end
    return UI.ComboBox {choices = choices}
  end,
  prompt = "#emo__shunshi-prompt",
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    if #selected == 0 and self.interaction.data then
      local to = Fk:currentRoom():getPlayerById(to_select)
      if self.interaction.data == "emo__zedao_1_2" then
        return not to:isNude()
      elseif self.interaction.data == "emo__zedao_3_1" then
        return to:isWounded()
      else
        return true
      end 
    end
  end,
  can_use = function(self, player)
    if player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 then
      local mark = player:getTableMark("emo__zedao")
      return table.find(mark, function (m) return m ~= "x" end)
    end
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    local mark = player:getTableMark("emo__zedao")
    local num = tonumber( string.sub(self.interaction.data, -3, -3) )
    if not num then return end
    local m = mark[num]
    local new_m
    if m:startsWith("_") then
      new_m = "x"
    else
      local index = tonumber( string.sub(m, -1, -1) )
      new_m = "_"..string.sub(m, 1, -2)..((index % 2) + 1)
    end
    doZedao(player, to, num, true)
    if not player.dead then
      mark[num] = new_m
      room:setPlayerMark(player, "emo__zedao", mark)
      updataZedaoMark(player)
    end
  end,
}
moe__wangyue:addSkill(emo__shunshi)

Fk:loadTranslationTable{
  ["moe__wangyue"] = "望月",

  ["emo__zedao"] = "择道",
  [":emo__zedao"] = "锁定技，游戏开始时，你执行三次选择，在对应时机执行选择的效果："..
  "<br>1.每当你使用【杀】指定目标后，摸一张牌/弃置目标一张牌；"..
  "<br>2.每当你受到伤害后，你摸一张锦囊牌/基本牌；"..
  "<br>3.每当一名角色首次进入濒死状态时，你可以令其回复一点体力/对其造成一点伤害。",

  ["@emo__zedao"] = "择道",
  ["#emo__zedao-choice1"] = "择道：选择 使用【杀】指定目标后的效果",
  ["#emo__zedao-choice2"] = "择道：选择 受到伤害后的效果",
  ["#emo__zedao-choice3"] = "择道：选择 一名角色首次进入濒死状态的效果",
  ["#emo__zedao-recover"] = "择道：可以令 %src 回复一点体力",
  ["#emo__zedao-damage"] = "择道：可以对 %src 造成一点伤害",

  ["emo__zedao_1_1"] = "摸一张牌",
  ["emo__zedao_1_2"] = "弃置其一张牌",
  ["emo__zedao_2_1"] = "摸一张锦囊牌",
  ["emo__zedao_2_2"] = "摸一张基本牌",
  ["emo__zedao_3_1"] = "令其回复一点体力",
  ["emo__zedao_3_2"] = "对其造成一点伤害",
  ["log_emo__zedao_1_1"] = "摸",
  ["log_emo__zedao_1_2"] = "弃",
  ["log_emo__zedao_2_1"] = "锦",
  ["log_emo__zedao_2_2"] = "基",
  ["log_emo__zedao_3_1"] = "回",
  ["log_emo__zedao_3_2"] = "伤",
  
  ["emo__shunshi"] = "顺世",
  [":emo__shunshi"] = "出牌阶段限一次，你可以令一名角色执行〖择道〗一个选项的效果，然后若此选项未被改变过，则将此选项改为另一个效果，否则移除此选项。",
  ["#emo__shunshi-prompt"] = "顺世：对一名角色执行〖择道〗一个选项的效果",
}

local moe__xiaomie = General(extension, "moe__xiaomie", "moe", 4, 4, General.Female)

local emo__jika = fk.CreateTriggerSkill{
  name = "emo__jika",
  events = {fk.CardUsing, fk.CardResponding, fk.Death},
  can_trigger = function(self, event, target, player, data)
    if event ~= fk.Death then
      if player == target and player:hasSkill(self) and data.card.suit ~= Card.NoSuit then
        return not table.find(player:getPile(self.name), function (id)
          local card = Fk:getCardById(id)
          return card.type == data.card.type and card.suit == data.card.suit
        end)
      end
    else
      return player == target and player:hasSkill(self,true) and #player:getPile(self.name) > 0
    end
  end,
  on_cost = function (self, event, target, player, data)
    if event ~= fk.Death then return true end
    local tos = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#emo__jika-choose", self.name, true)
    if #tos > 0 then
      self.cost_data = tos[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event ~= fk.Death then
      local id = table.find(room.draw_pile, function (id)
        local card = Fk:getCardById(id)
        return card.type == data.card.type and card.suit == data.card.suit
      end)
      if not id then return end
      player:addToPile(self.name, id, true, self.name)
      if not player.dead then
        player:drawCards(1, self.name)
      end
    else
      local to = room:getPlayerById(self.cost_data)
      room:obtainCard(to, player:getPile(self.name), false, fk.ReasonPrey)
    end
  end,
}

moe__xiaomie:addSkill(emo__jika)

local emo__quanji = fk.CreateTriggerSkill{
  name = "emo__quanji",
  frequency = Skill.Wake,
  events = {fk.EventPhaseStart},
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and player:hasSkill(self) and target == player
    and player.phase == Player.Finish
  end,
  can_wake = function(self, event, target, player, data)
    return #player:getPile("emo__jika") == 12
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if #player:getPile("emo__jika") > 0 then
      room:obtainCard(player, player:getPile("emo__jika"), false, fk.ReasonPrey)
    end
    room:changeMaxHp(player, 1)
    if not player.dead and player:isWounded() then
      room:recover { num = 1, skillName = self.name, who = player, recoverBy = player}
    end
    room:handleAddLoseSkills(player, "-emo__jika|emo__chaoxian", nil)
  end,
}
moe__xiaomie:addSkill(emo__quanji)

local emo__chaoxian = fk.CreateTriggerSkill{
  name = "emo__chaoxian",
  events = {fk.CardUsing},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if player == target and player:hasSkill(self) then
      return data.toCard
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, self.name)
  end
}

local emo__chaoxian_targetmod = fk.CreateTargetModSkill{
  name = "#emo__chaoxian_targetmod",
  frequency = Skill.Compulsory,
  bypass_times = function (self, player, skill, scope, card)
    return player:hasSkill(emo__chaoxian) and card
  end,
  bypass_distances = function (self, player, skill, card)
    return player:hasSkill(emo__chaoxian) and card
  end,
  extra_target_func = function(self, player, skill, card)
    if player:hasSkill(emo__chaoxian) and card 
    and (skill.trueName == "slash_skill" or (card:isCommonTrick() and not card.multiple_targets)) then
      return 1
    end
  end,
}
emo__chaoxian:addRelatedSkill(emo__chaoxian_targetmod)
moe__xiaomie:addRelatedSkill(emo__chaoxian)

Fk:loadTranslationTable{
  ["moe__xiaomie"] = "小咩",

  ["emo__jika"] = "集卡",
  [":emo__jika"] = "①每当你使用或打出一张牌时，若你武将牌上没有与之类型、花色均相同的牌，你将牌堆一张与之类型、花色均相同牌置于武将牌上称为“卡”，并摸一张牌。②当你死亡时，可以令一名其他角色获得所有“卡”。",
  ["#emo__jika-choose"] = "集卡：可以令一名其他角色获得所有“卡”",

  ["emo__quanji"] = "全集",
  [":emo__quanji"] = "觉醒技，结束阶段，若你有12张“卡”，你获得所有“卡”，增加1点体力上限并回复1点体力，失去〖集卡〗并获得〖超限〗。",

  ["emo__chaoxian"] = "超限",
  [":emo__chaoxian"] = "锁定技，你使用牌没有距离和次数限制，使用【杀】和单体普通锦囊的目标上限+1。当你使用目标为牌的牌时，摸两张牌。",
  
  ["$emo__quanji1"] = "终于全了！",
  ["$emo__quanji2"] = "好耶！",
}

local moe__jielei = General(extension, "moe__jielei", "moe", 3, 3, General.Female)
moe__jielei.shield = 1

local emo__duizhuo = fk.CreateActiveSkill{
  name = "emo__duizhuo",
  anim_type = "support",
  card_num = 0,
  target_num = 1,
  prompt = function ()
    return "#emo__duizhuo-prompt:::"..(Self:getHandcardNum() + 1)
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    local x = player:getHandcardNum() + 1
    local piles = table.filter(table.connect(room.draw_pile, room.discard_pile), function (id)
      local card = Fk:getCardById(id, true)
      return card.type == Card.TypeEquip and Fk:translate(card.name):len() == x
    end)
    if #piles > 0 then
      room:obtainCard(to, table.random(piles), true, fk.ReasonJustMove, nil, self.name)
    end
    local tos = {to}
    table.insertIfNeed(tos, player)
    for _, p in ipairs(tos) do
      if not p.dead and #p:getCardIds("he") > 1 then
        local _,dat = room:askForUseActiveSkill(p, "emo__duizhuo_recast", "#emo__duizhuo-card", true)
        if dat then
          room:recastCard(dat.cards, p, self.name)
          if not player.dead and not p:prohibitUse(Fk:cloneCard("analeptic")) and not p:isProhibited(p, Fk:cloneCard("analeptic")) then
            room:useVirtualCard("analeptic", nil, p, p, self.name, true)
          end
          break
        end
      end
    end
  end,
}
local emo__duizhuo_recast = fk.CreateActiveSkill{
  name = "emo__duizhuo_recast",
  card_num = 2,
  target_num = 0,
  card_filter = function(self, to_select, selected)
    if #selected == 0 then
      return true
    elseif #selected == 1 then
      return Fk:getCardById(to_select).color ~= Fk:getCardById(selected[1]).color
    end
    return false
  end,
}
Fk:addSkill(emo__duizhuo_recast)

moe__jielei:addSkill(emo__duizhuo)

local emo__guzui = fk.CreateTriggerSkill{
  name = "emo__guzui",
  events = {fk.CardEffectFinished},
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card.trueName == "analeptic" and not target.dead
  end,
  on_cost = function (self, event, target, player, data)
    local prompt = "#emo__guzui-recover"
    if (data.extra_data or {}).analepticRecover then
      prompt = "#emo__guzui-buff"
    end
    return player.room:askForSkillInvoke(player, self.name, nil, prompt..":"..data.to)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    target:drawCards(1, self.name)
    if target.dead then return end
    if (data.extra_data or {}).analepticRecover then
      target.drank = target.drank + 1 + ((data.extra_data or {}).additionalDrank or 0)
      room:broadcastProperty(target, "drank")
    else
      room:recover({
        who = target,
        num = 1,
        recoverBy = room:getPlayerById(data.from),
        card = data.card,
      })
    end
    if target.dead or player.dead then return end
    local targets = table.filter(room.alive_players, function(p) return p ~= player and p ~= target end)
    if #targets > 0 then
      local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__guzui-choose:"..target.id, self.name, true)
      if #tos > 0 then
        local to = room:getPlayerById(tos[1])
        local use = room:askForUseCard(target, "slash", "slash", "#emo__guzui-slash:"..to.id..":"..player.id, true, 
        {exclusive_targets = {to.id}, bypass_distances = true, bypass_times = true})
        if use then
          use.extraUse = true
          room:useCard(use)
          return
        end
      end
    end
    if target ~= player then
      local get = {}
      for _, color in ipairs({Card.Red, Card.Black}) do
        local cs = table.filter(target:getCardIds("h"), function (id) return Fk:getCardById(id).color == color end)
        if #cs > 0 then
          table.insert(get, table.random(cs))
        end
      end
      if #get > 0 then
        room:obtainCard(player, get, false, fk.ReasonGive, target.id, self.name)
      end
    end
  end,
}
moe__jielei:addSkill(emo__guzui)

Fk:loadTranslationTable{
  ["moe__jielei"] = "洁涙",
  ["#moe__jielei"] = "皓月争辉",

  ["emo__duizhuo"] = "对酌",
  [":emo__duizhuo"] = "出牌阶段限一次，你可以令一名角色从摸牌堆或弃牌堆获得一张牌名字数为X的装备牌，然后其可以重铸两张颜色不同的牌，视为使用一张【酒】，若其不执行，你可以如此做（X为发动技能时你的手牌数+1）。",
  ["#emo__duizhuo-card"] = "对酌：你可以重铸两张颜色不同的牌，视为使用一张【酒】",
  ["#emo__duizhuo-prompt"] = "对酌：你可令一名角色获得一张牌名字数为 %arg 的装备牌",
  ["emo__duizhuo_recast"] = "对酌",

  ["emo__guzui"] = "孤醉",
  [":emo__guzui"] = "每当【酒】对一名角色生效后，你可以令其摸一张牌并执行此【酒】的另一个效果(回复/加伤)，然后令其选一项：1.对你选择的角色使用一张【杀】；2.随机交给你每种颜色各一张手牌。",
  ["#emo__guzui-buff"] = "孤醉：你可以令 %src 摸一张牌且本回合下一张【杀】伤害+1",
  ["#emo__guzui-recover"] = "孤醉：你可以令 %src 摸一张牌并回复1点体力",
  ["#emo__guzui-choose"] = "孤醉：选择 %src 使用【杀】的目标",
  ["#emo__guzui-slash"] = "孤醉：请对 %src 使用一张【杀】，否则随机交给 %dest 每颜色各一张手牌",
}

local moe__liliang = General(extension, "moe__liliang", "moe", 3, 3, General.Female)

local emo__guizhi = fk.CreateActiveSkill{
  name = "emo__guizhi",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0 and Self.id ~= to_select and target:getMark("emo__guizhi_target-phase") == 0 and not target:isNude()
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.tos[1])
    room:setPlayerMark(to, "emo__guizhi_target-phase", 1)
    local get = room:askForCardChosen(player, to, "he", self.name)
    room:obtainCard(player, get, false, fk.ReasonPrey, player.id, self.name)
    if to.dead then return end
    local names = {}
    for _, id in ipairs(Fk:getAllCardIds()) do
      local card = Fk:getCardById(id)
      if card:isCommonTrick() and not card.is_derived and to:canUse(card) and not to:prohibitUse(card) then
        table.insertIfNeed(names, card.name)
      end
    end
    local extraNamaes = {"raid_and_frontal_attack"}
    for _, name in ipairs(extraNamaes) do
      if Fk.all_card_types[name] then
        local card = Fk:cloneCard(name)
        if to:canUse(card) and not to:prohibitUse(card) then
          table.insertIfNeed(names, name)
        end
      end
    end
    if #names == 0 then return end
    local choices = table.random(names, 3)
    local success, dat = room:askForUseViewAsSkill(to, "emo__guizhi_viewas", "#emo__guizhi-vs", true, {emo__guizhi_names = choices})
    if success and dat then
      local card = Fk:cloneCard(dat.interaction)
      card.skillName = self.name
      if not player.dead then
        local choice = room:askForChoice(player, choices, self.name, "#emo__guizhi-guess")
        if choice == card.name then
          if not player.dead then
            player:drawCards(1, self.name)
          end
          if not to.dead then
            to:drawCards(1, self.name)
          end
          player:addSkillUseHistory(self.name, -1)
        end
      end
      room:useCard{
        from = to.id,
        tos = table.map(dat.targets, function(p) return {p} end),
        card = card,
        extraUse = true,
      }
    end
  end,
}

local emo__guizhi_viewas = fk.CreateViewAsSkill{
  name = "emo__guizhi_viewas",
  interaction = function(self)
    return U.CardNameBox {choices = self.emo__guizhi_names}
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    if #cards ~= 0 or not self.interaction.data then return nil end
    local c = Fk:cloneCard(self.interaction.data)
    c.skillName = "emo__guizhi"
    return c
  end,
}
Fk:addSkill(emo__guizhi_viewas)

moe__liliang:addSkill(emo__guizhi)


local emo__tuotu = fk.CreateTriggerSkill{
  name = "emo__tuotu",
  anim_type = "offensive",
  frequency = Skill.Limited,
  events = {fk.AfterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useVirtualCard("volcanic_eruption", nil, player, room:getOtherPlayers(player), self.name)
  end,
}

local emo__tuotu_delay = fk.CreateTriggerSkill{
  name = "#emo__tuotu_delay",
  mute = true,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player.dead then return false end
    local e = player.room.logic:getCurrentEvent():findParent(GameEvent.CardEffect)
    if not e then return false end
    local effect = e.data[1]
    if effect.from == player.id and table.contains(effect.card.skillNames, "emo__tuotu") then
      local ids = {}
      for _, move in ipairs(data) do
        if (move.moveReason == fk.ReasonDiscard or move.moveReason == fk.ReasonJudge) then
          for _, info in ipairs(move.moveInfo) do
            if player.room:getCardArea(info.cardId) == Card.DiscardPile then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
      end
      if #ids > 0 then
        self.cost_data = ids
        return true
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:obtainCard(player, self.cost_data, true, fk.ReasonPrey)
  end,
}
emo__tuotu:addRelatedSkill(emo__tuotu_delay)

moe__liliang:addSkill(emo__tuotu)

Fk:loadTranslationTable{
  ["moe__liliang"] = "栗良",

  ["emo__guizhi"] = "诡智",
  [":emo__guizhi"] = "出牌阶段限一次，你可以获得一名其他角色的一张牌，然后其从三个随机普通锦囊牌中选择一个并视为使用之。使用此牌前，你从这三个牌名猜测其使用的牌名，若猜对，你与其各摸一张牌，〖诡智〗视为未发动且本阶段不能选择该角色。",
  ["emo__guizhi_viewas"] = "诡智",
  ["#emo__guizhi-vs"] = "诡智：视为使用一张普通锦囊牌",
  ["#emo__guizhi-guess"] = "诡智：猜测其使用的锦囊牌，猜对则与其摸牌",

  ["emo__tuotu"] = "脱兔",
  [":emo__tuotu"] = "限定技，当你脱离濒死状态时，你可以视为使用一张【火山爆发】，然后你获得因此牌的效果而判定或弃置的牌。",
  ["emo__tuotu_delay"] = "脱兔",
  
  ["$emo__tuotu1"] = "真的生气啦！！！",
  ["$emo__tuotu2"] = "烧起来！",
}

local moe__qianxu = General(extension, "moe__qianxu", "moe", 3, 3, General.Female)

local emo__duanyin = fk.CreateTriggerSkill{
  name = "emo__duanyin",
  anim_type = "drawcard",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player:getMark("@emo__duanyin") == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cardsMap = {}
    local cards = table.simpleClone(room.draw_pile)
    table.insertTable(cards, room.discard_pile)
    for _, id in ipairs(cards) do
      local suit = Fk:getCardById(id):getSuitString()
      if suit ~= "nosuit" then
        cardsMap[suit] = cardsMap[suit] or {}
        table.insert(cardsMap[suit], id)
      end
    end
    local get = U.getRandomCards(cardsMap, 4)
    if #get > 0 then
      room:setPlayerMark(player, "@emo__duanyin", {"log_spade","log_club","log_diamond","log_heart"})
      room:moveCardTo(get, Player.Hand, player, fk.ReasonPrey, self.name)
    end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    return player:getMark("@emo__duanyin") ~= 0
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    local mark = player:getMark("@emo__duanyin")
    for _, move in ipairs(data) do
      if move.from == player.id and move.moveReason ~= fk.ReasonUse then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
            table.removeOne(mark, Fk:getCardById(info.cardId):getSuitString(true))
          end
        end
      end
    end
    room:setPlayerMark(player, "@emo__duanyin", #mark > 0 and mark or 0)
  end,
}
moe__qianxu:addSkill(emo__duanyin)

local emo__qunlie = fk.CreateActiveSkill{
  name = "emo__qunlie",
  anim_type = "control",
  can_use = function(self, player)
    return not player:isNude() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  min_card_num = 1,
  card_filter = function(self, to_select, selected)
    return not Self:prohibitDiscard(Fk:getCardById(to_select))
  end,
  min_target_num = 1,
  target_filter = function(self, to_select, selected, cards)
    return #selected < #cards
  end,
  feasible = function(self, selected, selected_cards)
    return #selected > 0 and #selected_cards > 0 and #selected_cards == #selected
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:throwCard(effect.cards, self.name, player, player)
    for _, pid in ipairs(effect.tos) do
      local p = room:getPlayerById(pid)
      if not p.dead then
        room:addPlayerMark(p, "@!hunting")
      end
    end
  end,
}
moe__qianxu:addSkill(emo__qunlie)

Fk:loadTranslationTable{
  ["moe__qianxu"] = "千绪",

  ["emo__duanyin"] = "断音",
  [":emo__duanyin"] = "每当你使用牌后，你可以获得四种花色各一张牌，然后〖断音〗失效直到你非因使用而失去四种花色的牌。",
  ["@emo__duanyin"] = "断音",

  ["emo__qunlie"] = "群猎",
  [":emo__qunlie"] = "出牌阶段限一次，你可以弃置任意张牌，令等量的角色获得1枚“狩猎”标记。"..
  "<br><font color='grey'>“狩猎”标记：受到有来源的1点伤害时，移除1个标记，伤害来源摸一张牌。",
}

local moe__huaqing = General(extension, "moe__huaqing", "moe", 3, 3, General.Female)

local emo__panjie = fk.CreateTriggerSkill{
  name = "emo__panjie",
  anim_type = "control",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player and data.card.suit ~= Card.NoSuit then
      return table.find(player.room.alive_players, function (p)
        return table.find(p:getCardIds("e"), function (id)
          return Fk:getCardById(id).suit == data.card.suit
        end)
      end)
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local _, dat = room:askForUseActiveSkill(player, "emo__panjie_active", 
    "#emo__panjie-invoke:::"..data.card:getSuitString(true), true, {emo__panjie_suit = data.card.suit})
    if dat then
      self.cost_data = {tos = dat.targets}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local from = room:getPlayerById(self.cost_data.tos[1])
    local to = room:getPlayerById(self.cost_data.tos[2])
    local cards = table.filter(from:getCardIds("e"), function (id)
      return Fk:getCardById(id).suit == data.card.suit and #to:getAvailableEquipSlots(Fk:getCardById(id).sub_type) > 0
    end)
    if #cards == 0 then return end
    local cardId = (#cards == 1) and cards[1] or 
    room:askForCardChosen(player, from, { card_data = { { self.name, cards } } }, self.name)
    room:moveCardIntoEquip(to, cardId, self.name, true, player)
    room:useVirtualCard("slash", nil, from, to, self.name, true)
  end,
}
moe__huaqing:addSkill(emo__panjie)

local emo__panjie_active = fk.CreateActiveSkill{
  name = "emo__panjie_active",
  card_num = 0,
  target_num = 2,
  target_filter = function(self, to_select, selected)
    if #selected > 1 then return false end
    local from = Fk:currentRoom():getPlayerById(#selected == 0 and to_select or selected[1])
    local mark = Self:getTableMark("emo__panjie-round")
    local cards = table.filter(from:getCardIds("e"), function (id)
      return not table.contains(mark, id) and Fk:getCardById(id).suit == self.emo__panjie_suit
    end)
    if #cards == 0 then return false end
    if #selected == 1 then
      local to = Fk:currentRoom():getPlayerById(to_select)
      return table.find(cards, function (id)
        return #to:getAvailableEquipSlots(Fk:getCardById(id).sub_type) > 0
      end)
    end
    return true
  end,
  card_filter = Util.FalseFunc,
}
Fk:addSkill(emo__panjie_active)

local emo__panzhi = fk.CreateTriggerSkill{
  name = "emo__panzhi",
  events = {fk.TurnEnd},
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and not target.dead then
      local events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
        local use = e.data[1]
        return use.from == player.id
      end, Player.HistoryTurn)
      if #events == 0 then
        events = player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function(e)
          return e.data[1] == player
        end, Player.HistoryTurn)
        return #events == 0
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    self.cost_data = {tos = {target.id}}
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__panzhi-invoke:"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local ids = room:getCardsFromPileByRule(".|.|.|.|.|equip")
    if #ids == 0 then return end
    room:moveCardTo(ids, Card.Processing, nil, fk.ReasonJustMove, self.name, nil, true, player.id)
    local all_choices = {"#emo__panzhi-use", "#emo__panzhi-slash", "Cancel"}
    local equip = Fk:getCardById(ids[1])
    local slash = Fk:cloneCard("slash")
    slash:addSubcard(ids[1])
    slash.skillName = self.name
    local choices = {"Cancel"}
    if target:canUse(equip) then
      table.insert(choices, 1, all_choices[1])
    end
    if player:canUseTo(slash, target, {bypass_times = true}) then
      table.insert(choices, 2, all_choices[2])
    end
    local choice = room:askForChoice(player, choices, self.name, 
    "#emo__panzhi-choice::"..target.id..":"..equip:toLogString(), false, all_choices)
    if choice == all_choices[1] then
      room:useCard {from  = target.id, tos = {{target.id}}, card = equip}
      if not player.dead then
        player:drawCards(1, self.name)
      end
      if not target.dead then
        target:drawCards(1, self.name)
      end
    elseif choice == all_choices[2] then
      room:useCard {from  = player.id, tos = {{target.id}}, card = slash, extraUse = true}
      room:askForDiscard(player, 1, 1, true, self.name, false)
      room:askForDiscard(target, 1, 1, true, self.name, false)
    end
    room:cleanProcessingArea(ids, self.name)
  end,
}
moe__huaqing:addSkill(emo__panzhi)

Fk:loadTranslationTable{
  ["moe__huaqing"] = "花情",
  ["#moe__huaqing"] = "燕过留情",

  ["emo__panjie"] = "盘结",
  [":emo__panjie"] = "每当你使用一张牌后，你可以移动场上一张与此牌花色相同的装备牌（替换原装备），然后令失去此装备的角色视为对得到此装备的角色使用一张【杀】。",
  ["emo__panjie_active"] = "盘结",
  ["#emo__panjie-invoke"] = "盘结：你可移动场上一张%arg装备牌，令失去此牌的角色视为对得到的角色使用【杀】",

  ["emo__panzhi"] = "攀枝",
  [":emo__panzhi"] = "一名角色回合结束时，若你于本回合未改变体力且未使用牌，你可以亮出牌堆顶一张装备牌，然后可选一项：1.令其使用之，与其各摸一张牌；2.将此牌当【杀】对其使用，与其各弃置一张牌。",
  ["#emo__panzhi-invoke"] = "攀枝：你可亮出牌堆顶一张装备牌，选择令 %src 使用之或将此牌当【杀】对其使用",
  ["#emo__panzhi-use"] = "令其使用，与其各摸牌",
  ["#emo__panzhi-slash"] = "当杀对其使用，与其各弃牌",
  ["#emo__panzhi-choice"] = "攀枝：你亮出了 %arg ，选择令 %dest 使用之，或将此牌当【杀】对其使用",
}

local moe__feibi = General(extension, "moe__feibi", "moe", 3, 3, General.Female)

local emo__xuyu = fk.CreateTriggerSkill{
  name = "emo__xuyu",
  anim_type = "control",
  events = {fk.CardUsing, fk.CardResponding},
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and player:distanceTo(target) == 1 and not target.dead
    and data.responseToEvent and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__xuyu-invoke:"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    target:drawCards(2, self.name)
    if target.dead or player.dead or target:isNude() then return end
    local cards = room:askForDiscard(target, 2, 2, true, self.name, false)
    cards = table.filter(cards, function(id)
      return room:getCardArea(id) == Card.DiscardPile
    end)
    if #cards > 0 then
      local card = room:askForCardChosen(player, target, { card_data = { { self.name, cards } } }, self.name)
      room:obtainCard(player, card, true, fk.ReasonPrey, player.id, self.name)
    end
  end,
}
moe__feibi:addSkill(emo__xuyu)

local emo__moqiu = fk.CreateTriggerSkill{
  name = "emo__moqiu",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  frequency = Skill.Compulsory,
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local suits = {}
    room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
      local use = e.data[1]
      if use.card.suit ~= Card.NoSuit then
        table.insertIfNeed(suits, use.card.suit)
      end
      return #suits == 4
    end, Player.HistoryTurn)
    local n = #suits
    if n == 0 then return end
    if room:askForSkillInvoke(player, self.name, nil, "#emo__moqiu-invoke:::"..n) then
      self.cost_data = n
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = self.cost_data
    player:drawCards(n, self.name)
    local all = room:getOtherPlayers(player)
    if player.dead or #all == 0 then return end
    local num = 9999
    for _, p in ipairs(all) do
      num = math.min(num, math.abs(player:getHandcardNum() - p:getHandcardNum()))
    end
    local targets = table.filter(all, function (p)
      return math.abs(player:getHandcardNum() - p:getHandcardNum()) == num
    end)
    local tos = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#emo__moqiu-choose", self.name, true)
    if #tos > 0 then
      local to = room:getPlayerById(tos[1])
      room:handleAddLoseSkills(player, "-"..self.name)
      room:handleAddLoseSkills(to, self.name)
    end
  end,
}
moe__feibi:addSkill(emo__moqiu)

Fk:loadTranslationTable{
  ["moe__feibi"] = "菲比",

  ["emo__xuyu"] = "絮语",
  [":emo__xuyu"] = "每回合限一次，每当你计算距离为1的角色响应牌时，你可以令其摸两张牌再弃置两张牌，然后你获得其弃置的牌中一张牌。",
  ["#emo__xuyu-invoke"] = "絮语：你可令 %src 摸两张牌再弃置两张牌，然后你获得其弃置的牌中一张牌",

  ["emo__moqiu"] = "魔球",
  [":emo__moqiu"] = "结束阶段，你可以摸X张牌（X为本回合被使用过的花色数），若如此做，你可以失去〖魔球〗，并令与你手牌数之差最小的一名其他角色获得之。",
  ["#emo__moqiu-invoke"] = "魔球：你可以摸 %arg 张牌",
  ["#emo__moqiu-choose"] = "魔球：你可失去〖魔球〗，令手牌数与你最接近的一名角色获得之",
}

local moe__selunna = General(extension, "moe__selunna", "moe", 3, 3, General.Female)

local emo__mijiao = fk.CreateTriggerSkill{
  name = "emo__mijiao",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.phase == Player.Play and player:usedSkillTimes(self.name, Player.HistoryRound) < player.hp
    and not target.dead
  end,
  on_cost = function (self, event, target, player, data)
    self.cost_data = {tos = {target.id}}
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__mijiao-invoke:"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local colors = {"black", "red"}
    local color = room:askForChoice(player, colors, self.name)
    local types = {"basic", "trick", "equip"}
    local cardType = room:askForChoice(player, types, self.name)
    local suit = (color == "red" and "heart,diamond" or "spade,club")
    local pattern = ".|.|".. suit .. "|.|.|" .. cardType
    local mark = target:getTableMark("@emo__mijiao-phase")
    table.insert(mark, color)
    table.insert(mark, cardType.."_char")
    room:setPlayerMark(target, "@emo__mijiao-phase", mark)
    local ids = room:getCardsFromPileByRule(pattern, 2, "allPiles")
    if #ids > 0 then
      room:obtainCard(target, ids, true, fk.ReasonPrey)
    end
  end,
}

local emo__mijiao_delay = fk.CreateTriggerSkill{
  name = "#emo__mijiao_delay",
  anim_type = "negative",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return not player.dead and not player:isKongcheng() and target == player and player:getMark("@emo__mijiao-phase") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getMark("@emo__mijiao-phase")
    for i = 1, #mark / 2 do
      if player.dead or player:isKongcheng() then break end
      local color = mark[i]
      local cardType = mark[i+1]
      cardType = string.sub(cardType, 1, #cardType - 5)
      local cards = table.filter(target:getCardIds("h"), function (id)
        local c = Fk:getCardById(id)
        return not target:prohibitDiscard(c) and c:getColorString() ~= color and c:getTypeString() ~= cardType
      end)
      if #cards > 0 then
        room:throwCard(cards, self.name, target, target)
      end
    end
  end,
}
emo__mijiao:addRelatedSkill(emo__mijiao_delay)

moe__selunna:addSkill(emo__mijiao)

local emo__ciai = fk.CreateTriggerSkill{
  name = "emo__ciai",
  anim_type = "defensive",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and not player:isNude()
    and data.from and data.from ~= player and not data.from.dead and not data.from:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    local cards = player.room:askForCard(player, 1, 3, true, self.name, true, ".", "#emo__ciai-invoke:"..data.from.id)
    if #cards > 0 then
      self.cost_data = {cards = cards, tos = {data.from.id}}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local from = data.from
    local my_cards = self.cost_data.cards
    local ur_cards = room:askForCard(from, 1, 3, true, self.name, false, ".", "#emo__ciai-card:"..player.id)
    local moveInfos = {}
    local cardsMap = {my_cards, ur_cards}
    local targets = {player, from}
    for i, p in ipairs(targets) do
      table.insert(moveInfos, {
        ids = cardsMap[i],
        from = p.id,
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonRecast,
        proposer = p.id,
        skillName = self.name,
      })
      room:sendLog{
        type = "#RecastBySkill",
        from = p.id,
        card = cardsMap[i],
        arg = self.name,
      }  
    end
    room:moveCards(table.unpack(moveInfos))
    room:broadcastPlaySound("./audio/system/recast")
    for i, p in ipairs(targets) do
      if not p.dead then
        p:drawCards(#cardsMap[i], self.name)
      end
    end
    local num = math.abs(#cardsMap[1] - #cardsMap[2])
    if num == 0 then
      if not player.dead and player:isWounded() then
        room:recover { num = 1, skillName = self.name, who = player, recoverBy = player }
      end
    elseif num == 1 then
      if not player.dead then
        player:drawCards(1, self.name)
      end
    elseif num == 2 and not from.dead then
      room:doIndicate(player.id, {from.id})
      room:damage { from = target, to = from, damage = 1, skillName = self.name }
    end
  end,
}
moe__selunna:addSkill(emo__ciai)

Fk:loadTranslationTable{
  ["moe__selunna"] = "瑟伦娜",
  ["#moe__selunna"] = "秘教引路人",

  ["emo__mijiao"] = "秘教",
  [":emo__mijiao"] = "每轮限X次，一名角色的出牌阶段开始时，你可以声明一种颜色和一种类别，令其获得两张均符合此颜色和此类型的牌，若如此做，本阶段结束时，令其弃置其所有不为此颜色且不为此类别的手牌（X为你体力值）。",
  ["#emo__mijiao-invoke"] = "秘教：你可以令 %src 获得两张其指定颜色、类别的牌",
  ["#emo__mijiao_delay"] = "秘教",
  ["@emo__mijiao-phase"] = "秘教",

  ["emo__ciai"] = "慈哀",
  [":emo__ciai"] = "每当你受到其他角色造成的伤害后，你与伤害来源同时重铸一至三张牌，若双方重铸的牌数之差：为0，你回复一点体力；为1，你摸一张牌；为2，你对该角色造成1点伤害。",
  ["#emo__ciai-invoke"] = "慈哀：你可以与 %src 同时重铸1-3张牌",
  ["#emo__ciai-card"] = "慈哀：请重铸1-3张牌，若重铸牌张数与 %src 相同，其回复体力；若张数之差为2，你受到伤害",
}

local moe__jianglan = General(extension, "moe__jianglan", "moe", 3, 3, General.Female)

local emo__xunyao = fk.CreateTriggerSkill{
  name = "emo__xunyao",
  events = {fk.RoundStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self)
  end,
  on_cost = function (self, event, target, player, data)
    local tos = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1, "#emo__xunyao-choose", self.name, true)
    if #tos > 0 then
      self.cost_data = {tos = tos}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    local types = {}
    for i = 1, 3 do
      if to.dead then break end
      local pattern = (#types > 0) and (".|.|.|.|.|^("..table.concat(types, ",")..")") or "."
      local judge = {
        who = to,
        reason = self.name,
        pattern = pattern,
        skipDrop = true, 
      }
      room:judge(judge)
      table.insertIfNeed(types, judge.card:getTypeString())
      local cardId = judge.card:getEffectiveId()
      if room:getCardArea(cardId) == Card.Processing then
        if not to.dead and Exppattern:Parse(pattern):match(judge.card) then
          room:obtainCard(to, cardId, true, fk.ReasonJustMove, to.id, self.name)
        else
          room:moveCardTo(cardId, Card.DiscardPile, nil, fk.ReasonJudge)
        end
      end
    end
    if not to.dead and #types < 3 and to ~= player then
      self.cost_data = {tos = {player.id}}
      self:use(event, target, player, data)
    end
  end,
}

moe__jianglan:addSkill(emo__xunyao)

local emo__jiexiang = fk.CreateTriggerSkill{
  name = "emo__jiexiang",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    local cards = {}
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonJudge then
        for _, info in ipairs(move.moveInfo) do
          table.insertIfNeed(cards, info.cardId)
        end
      end
    end
    cards = table.filter(cards, function(id) return player.room:getCardArea(id) == Card.DiscardPile end)
    if #cards > 0 then
      self.cost_data = cards
      return true
    end
  end,
  on_cost = function (self, event, target, player, data)
    local use = U.askForUseRealCard(player.room, player, self.cost_data, ".", self.name, 
    "#emo__jiexiang-use", {expand_pile = self.cost_data}, true, true)
    if use then
      self.cost_data = use
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:useCard(self.cost_data)
  end,
}
moe__jianglan:addSkill(emo__jiexiang)

Fk:loadTranslationTable{
  ["moe__jianglan"] = "绛澜",

  ["emo__xunyao"] = "寻瑶",
  [":emo__xunyao"] = "每轮开始时，你可以令一名角色判定三次，若判定牌与已判定的类型均不同，其获得之，若其不为你且获得牌小于三张，你对自己发动〖寻瑶〗。",
  ["#emo__xunyao-choose"] = "寻瑶：你可以令一名角色判定三次，其可能获得判定牌",
  ["#emo__xunyao_delay"] = "寻瑶",
  ["@@emo__xunyao-inhand"] = "寻瑶",

  ["emo__jiexiang"] = "解香",
  [":emo__jiexiang"] = "每当判定牌进入弃牌堆时，你可使用之。",
  ["#emo__jiexiang-use"] = "解香：你可使用此牌",
}

local moe__meiying = General(extension, "moe__meiying", "moe", 3, 3, General.Female)

local emo__jiliu = fk.CreateTriggerSkill{
  name = "emo__jiliu",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:getMark("emo__jiliu-round") == 0 and data.card.is_damage_card and data.damageDealt then
      local damage_event = player.room.logic:getActualDamageEvents(1, function(e)
        local damage = e.data[1]
        return damage.card ~= nil and damage.card.is_damage_card
      end, Player.HistoryRound)
      return #damage_event > 0 and damage_event[1].data[1].card == data.card
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@emo__jiliu-round", data.card.trueName)
    local n = 0
    for _, num in pairs(data.damageDealt) do
      n = n + num
    end
    player:drawCards(n, self.name)
    if player.dead then return end
    local choices = {"emo__jiliu_defend", "emo__jiliu_damage"}
    local choice = room:askForChoice(player, choices, self.name, "#emo__jiliu-choice:::"..data.card.trueName)
    room:setPlayerMark(player, "emo__jiliu-round", choice)
  end,
}

local emo__jiliu_delay = fk.CreateTriggerSkill{
  name = "#emo__jiliu_delay",
  events = {fk.TargetConfirming, fk.CardUsing},
  mute = true,
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if event == fk.TargetConfirming then
      return target == player and data.card.trueName == player:getMark("@emo__jiliu-round")
      and player:getMark("emo__jiliu-round") == "emo__jiliu_defend"
    else
      return data.card.trueName == player:getMark("@emo__jiliu-round") and player:getMark("emo__jiliu-round") == "emo__jiliu_damage"
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetConfirming then
      room:notifySkillInvoked(player, self.name, "defensive")
      local judge = {
        who = player,
        reason = "emo__jiliu",
        pattern = ".|.|^spade",
      }
      room:judge(judge)
      if judge.card.suit ~= Card.Spade then
        AimGroup:cancelTarget(data, player.id)
        return true
      end
    else
      room:notifySkillInvoked(player, self.name, "offensive")
      data.additionalDamage = (0 or data.additionalDamage) + 1
    end
  end,
}
emo__jiliu:addRelatedSkill(emo__jiliu_delay)

moe__meiying:addSkill(emo__jiliu)

local emo__wuyou = fk.CreateTriggerSkill{
  name = "emo__wuyou",
  anim_type = "offensive",
  events = {fk.CardEffectCancelledOut},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) < 1 and data.card.trueName == "slash"
      and data.to ~= player.id and not player.room:getPlayerById(data.to):isNude()
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#emo__wuyou-invoke:"..data.to..":"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    local cid = room:askForCardChosen(player, to, "he", self.name)
    room:moveCardTo(cid, Player.Hand, player, fk.ReasonPrey, self.name, nil, false, player.id)
    if not to.dead then
      room:useVirtualCard("duel", nil, to, target, self.name)
    end
  end,
}

moe__meiying:addSkill(emo__wuyou)

Fk:loadTranslationTable{
  ["moe__meiying"] = "魅莺",

  ["emo__jiliu"] = "击流",
  [":emo__jiliu"] = "锁定技，当一张伤害牌结算完毕后，若此牌为本轮第一张造成伤害的伤害牌，你摸等同于此牌造成伤害值张牌，然后选一项：1.本轮你成为此牌名的牌的目标时进行判定，若结果不为♠则取消之；2.本轮此牌名的牌造成伤害+1。",
  ["#emo__jiliu_delay"] = "击流",
  ["emo__jiliu_defend"] = "你成为此牌目标时判定，不为♠则取消",
  ["emo__jiliu_damage"] = "此牌造成伤害+1",
  ["#emo__jiliu-choice"] = "击流：选择【%arg】于本轮产生的效果",
  ["@emo__jiliu-round"] = "击流",

  ["emo__wuyou"] = "无忧",
  [":emo__wuyou"] = "每回合一次，每当一名其他角色抵消【杀】时，你可以获得其一张牌，然后其视为对此【杀】的使用者使用一张【决斗】。",
  ["#emo__wuyou-invoke"] = "无忧：你可以获得 %src 一张牌，然后其视为对 %dest 使用【决斗】",
}















--[[

Fk:loadTranslationTable{
  [""] = "",

  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",

  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
  [""] = "",
}

--]]




return extension

